bigwheat
10-20-2000, 01:59 PM
I am getting a type mismatch error when trying to write info from my form to an already existing table in an access database. Here is the code:
Function addtodatabase()
Set rs = db.OpenRecordset("SELECT testkey.* FROM
testkey")
With rs
.AddNew
.Fields("testid").Value = txttestid
.Fields("numquest").Value = txtnumq
.Update
.Close
End With
End Function
Private Sub cmdadd_Click()
Call addtodatabase(txttestid, txtnumq)
End Sub
I have code to open the database in the formload procedure. I know that it is probably some stupid mistake that I am just not seeing. Any help would be greatly appreciated.
Also, is it possible to write to a db field as an array?
For example, I have fields in a table named q1 through q50. My life would much easier if I could put it in a for/next loop and add the number there. I tried it this way, and it didn't work: (cans() are the txtboxes on my form)
for x = 1 to 50
.Fields("q"&x).Value = cans(x)
next x
Thanks again for any help!
Function addtodatabase()
Set rs = db.OpenRecordset("SELECT testkey.* FROM
testkey")
With rs
.AddNew
.Fields("testid").Value = txttestid
.Fields("numquest").Value = txtnumq
.Update
.Close
End With
End Function
Private Sub cmdadd_Click()
Call addtodatabase(txttestid, txtnumq)
End Sub
I have code to open the database in the formload procedure. I know that it is probably some stupid mistake that I am just not seeing. Any help would be greatly appreciated.
Also, is it possible to write to a db field as an array?
For example, I have fields in a table named q1 through q50. My life would much easier if I could put it in a for/next loop and add the number there. I tried it this way, and it didn't work: (cans() are the txtboxes on my form)
for x = 1 to 50
.Fields("q"&x).Value = cans(x)
next x
Thanks again for any help!