Update

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a field called A, when somone update the B field, I would like the A
field get updated.

Note:
A is text, B is Date, RequestID is Autonumber


I wrote the below code but nothing is happening when i update the Submite
Date field. :(


Private Sub B_AfterUpdate()

Dim strSQL As String
Dim db As DAO.Database
Set db = CurrentDb()

strSQL = "UPDATE Requests" _
& " SET Requests.A=" & "Right(,4) & '_' & [RequestID]" _
& " WHERE (((Requests.A) Is Null) AND ((Requests.) Is Not Null))"
db.Execute strSQL

End Sub
 
Max said:
I have a field called A, when somone update the B field, I would like the A
field get updated.

Note:
A is text, B is Date, RequestID is Autonumber


I wrote the below code but nothing is happening when i update the Submite
Date field. :(


Private Sub B_AfterUpdate()

Dim strSQL As String
Dim db As DAO.Database
Set db = CurrentDb()

strSQL = "UPDATE Requests" _
& " SET Requests.A=" & "Right(,4) & '_' & [RequestID]" _
& " WHERE (((Requests.A) Is Null) AND ((Requests.) Is Not Null))"
db.Execute strSQL

End Sub


Why are you doing this? It looks like the Date (B) and Autonumber
(RequestID) are already being stored in your record; why do you need to
store a value that is derived from them? You can recreate that value at any
time in a query.

I also note that your UPDATE doesn't reference the RequestID. You do realize
that your code will update every record where A is Null and B is not, don't
you?

Carl Rapson
 

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