Update table from form

marko

Registered User.
Local time
Today, 14:11
Joined
Dec 20, 2002
Messages
24
Hello everyone!

I'm trying to send results from my from to a table.
Results on the from are from query and some are typed in textboxes. Those from query are in combobox and one is in listbox which is the result from the combobox choice. Here's the code I'm trying to get to work (I've found this on the forum):

Private Sub Command61_Click()

Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("SELECT * FROM tblexpenses", dbopendynaset)
rst.MoveFirst
rst!eqpmntcode = cboEqpmnt
rst!downtime = downtime
rst!partcost = List0
rst!total = total
rst.Update
rst.Close

End Sub

When I run it, "invalid argument" error appears and lists this row: Set rst = CurrentDb.OpenRecordset("SELECT * FROM tblexpenses", dbopendynaset) error appears. What's wrong?

Thank you!

Marko
 
Try...

dim rst as DAO.recordset

If that doesn't work, you may need to add...
Microsoft DAO 3.6 Object Library
...to your references.

HTH
 
Thanks!

That part works, but the problem moved to this:
"No current record" and highlights rst.MoveFirst
I'm guessing there's an error in the fields that I'm trying to insert?

Marko
 
You're telling it to move to a record that doesn't exist(i.e there aren't any records in your recordset). You should try test to see that atleast one record exists b/4 trying to move through a recordset. Try...

If rst.RecordCount>0 then
end if

I use alot...

Do until rst.EOF
loop
 

Users who are viewing this thread

Back
Top Bottom