Solved Sql Update Error

mloucel

Member
Local time
Yesterday, 20:21
Joined
Aug 5, 2020
Messages
271
Hello All:

I got a problem with this statement:
Code:
Dim strSQL As String
strSQL = "UPDATE PatientT " & _
         "Set AuthCanceled = True " & _
         " Where PatientID = " & Me.PatientID
   Debug.Print strSQL
         CurrentDb.Execute strSQL, dbFailOnError
         MsgBox "Wait.."

This is the result using Debug:
" UPDATE PatientT Set AuthCanceled = True Where PatientID = 3 "

This is my first time trying to use SQL directly to VBA, and I got the following error:
Too Few Parameters expected 1

I have followed the example here:

AWF Example

But I cannot figure out what is my error, please any help will be appreciated, and if you can let me know what is the error so I can learn.

Maurice.
 
The SQL string in your post should be valid, assuming that the table is called "PatientT" and that table has two fields, called "AuthCanceled" and "PatientID".
Please copy and paste that SQL into a new query in SQL view. What error message does it raise, if any?
 
The SQL string in your post should be valid, assuming that the table is called "PatientT" and that table has two fields, called "AuthCanceled" and "PatientID".
Please copy and paste that SQL into a new query in SQL view. What error message does it raise, if any?
I appreciate the thumbs up. An answer to the question would be helpful as well.
 
I appreciate the thumbs up. An answer to the question would be helpful as well.
Sorry I was checking my code and I found out 2 things:

1] Thanks to you I figure out I was Dumb BLIND
2] I should have check twice with a clear mind.

well yes, you were right, I was wrong, Quote:
" The SQL string in your post should be valid, assuming "
The name of the table was the wrong one, I was NOT looking for PatientID, this is supposed to CANCEL a record in another table.
The Idea is that if the patient is deceased, any pre-authorization FOUND is no longer valid, so this little piece of code was supposed to do that, my problem is that I was working and finishing other stuff with the PatientT table, and I got confused, the code is corrected now thanks to you.

Code:
Dim strSQL As String
strSQL = "UPDATE AuthT " & _
         "Set AuthCanceled = True " & _
         " Where AuthID = " & Me.AuthID
   'Debug.Print strSQL
         CurrentDb.Execute strSQL, dbFailOnError
         'MsgBox "Wait.."

Thanks so much.

Maurice.
 

Users who are viewing this thread

Back
Top Bottom