dim statement stops code from working at all!

  • Thread starter Thread starter Perry
  • Start date Start date
P

Perry

Check in VBE (VBA IDE) under menu Tools | References
whether a reference is listed missing.
Most likely: DAO
Uncheck this missing entry and look for a more recent entry in the listing.

Addtly, you may need to extend all declarations in yr database project
explicitely pointing
to the DAO library, like in:

Dim db As DAO.Database
Dim rs As DAO.Recordset
....etc

Try again, repost of this doesn't remedy

Krgrds,
Perry
 
You need to change
rs.PartName = "Test"
to
rs.fields("PartName").value = "Test"
or
rs![PartName] = "test"

As you have it, It should have given you a compile error.


Rodrigo.
 
Check the command button is named Command9. If it is not, then, it would
never fire an event procedure called Command9_Click.

If it's not that, go to the code module of the form (containing that code).
Hilight the whole module, then press Ctrl-X (to cut the code), then Ctrl-V
(to paste it back). Sometimes event procedures get disconnected from their
controls. Cutting & repasting the code module will reconect them, where
required.

HTH,
TC
 
Hi

A friend has asked me to look at their database. They have a button on a
form with the code below associated with it. With the code as it is shown,
nothing happens when clicking the button. Not even the "hello" is shown. If
I comment out the Dim lines, the hello is shown but still nothing is added
to the tblParts_Ordered.

Can anyone shed light on this for me?
Thanks
Dave


Private Sub Command9_Click()
MsgBox ("hello")
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblParts_Ordered")
rs.AddNew
rs.PartName = "test"
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
 
Back
Top