Putting a value in a table

  • Thread starter Thread starter Rich
  • Start date Start date
R

Rich

Ok, hopefully I can explain this correctly. Here is the
code:
If IsNull(rstBillQry("Intercomp_Billing_Recon")) Then
DoCmd.OpenTable "S-Signings"
DoCmd.FindRecord rstBillQry("Signing_ID")
DoCmd.GoToControl "Intercomp_Billing_Recon"
????????????????????????????
End If

Basically, the value in the field Intercomp_Billing_Recon
is being pulled by creating a querydef called rstBillQry.
If the value in the field is Null, I want to put the
value "R" in the field. For some reason, I cannot write
the value straight into the rstBillQry recordset (I think
this is because it is a select query, but I could be
wrong) so I opted to open the table that is the source
of "Intercomp_Billing_Recon" and write it there. The code
takes me to the exact spot on the table where I want to
write "R". However, I cannot seem to write "R". Please
help if you can. Thank you.
 
don't use macro commands ;-)
do
Dim db As DAO.Database
'Dim rs as DAO.recordset etc, etc
set Db =Currentdb
db.execute "UPDATE S-Signings SET Intercomp_Billing_Recon='R' WHERE
Intercomp_Billing_Recon Is Null"

pieter
 
zap = "UPDATE S-Singnins SET S-Singnins.Signing_ID = "R"" &
" WHERE S-Singnins.Signing_ID = 'Intercomp_Billing_Recon';

CurrentDb.Execute za
 
This is what update queries are for :)

Dim strSQL as String
strSQL = "UPDATE [S-Signings] " _
& "SET [S-Signings].Intercomp_Billing_Recon " _
& "= 'R' " _
& "WHERE [S-Signings].Signing_ID='" _
& rstBillQry("Signing_ID") & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
 
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True

This is neater and safer:

db.Execute strSQL, dbFailOnError

If you've ever forgotten to reset SetWarnings you'll know what I mean...


Tim F
 
Back
Top