update query? - Form Object?

  • Thread starter Thread starter Fuzuy
  • Start date Start date
F

Fuzuy

I am running some difficulty, I try to update ID_req of Table
"documents" using ID# of another Table "Dwg_Spe_Cal_Dsheet" based on
a selection of ID from a Form. SQL is in the following, but I got "Run-
Time error '424', object required... however there is no complier
error, what is the "Object Required" means and know how to fix it?
Thanks for help....

If ((Dwg_Spe_Cal_Dsheet.[ID#]) = [Forms]![frmdwg_spe_cal_dsheet]!
[ID#]) And (documents.[ID_update] = True Or documents.[ID_update] =
Null) Then

If documents.[ID_update] Is Null Then
ssQ = "UPDATE documents Set documents.[ID_req] = Dwg_Spe_Cal_Dsheet.
[ID#];"
DoCmd.RunSQL ssQ
documents.[ID_update] = True
End If
If documents.[ID_update] = True Then
ssQ = "UPDATE documents Set documents.[ID_req] = ([ID_req] + "", "")
& Dwg_Spe_Cal_Dsheet.[ID#];"
DoCmd.RunSQL ssQ
End If
End If
 
It seems you use a table name as if it was an existing object, in VBA.
Remember that it is not because a table exists in the database that this
table also exists in VBA.


Dwg_Spe_Cal_Dsheet.[ID#] and documents.[ID_update] are acceptable inside
an SQL statement, but not in VBA. So, as example, the line:

ssQ = "UPDATE documents Set documents.[ID_req] =
Dwg_Spe_Cal_Dsheet.[ID#];"

is fine, since the reference to the table would occur inside an SQL
statement,

DoCmd.RunSQL ssQ

but

If documents.[ID_update] Is Null Then


is not an acceptable VBA statement because, probably, the object documents
does not exist, in VBA, at that point.

It may be that you want to open a recordset based on the table and then,
loop through each record of the recordset



Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top