Update Query in form

doran_doran

Registered User.
Local time
Today, 00:57
Joined
Aug 15, 2002
Messages
349
Can someone please verify my update code? this is behind form close. When closing the form I want system to look for empty field in ga_record_id_2 (text) and if it's empty then copy ga_record_id to ga_record_id_2.

When I run the sql in a seperate query it works. But it does not work in the form.

=============================================
Private Sub Form_Close()
Dim db As DAO.Database
Set db = CurrentDb()

If Me.GA_Record_ID_2 = "" Then
db.Execute "update tbl_groups " _
& "SET [tbl_groups].[GA_Record_ID_2] = [tbl_groups]![ga_record_id]" _
& "WHERE (tbl_groups.GA_Record_ID_2) Is Null;"
End If

db.close
set db=nothing

End Sub
=============================================

Thanks / Dianna
 
db.Execute "update tbl_groups " _
& "SET [tbl_groups].[GA_Record_ID_2] = [tbl_groups]![ga_record_id]" _
& " WHERE (tbl_groups.GA_Record_ID_2) Is Null;"
^
|
- if you don't have this space you have

[ga_record_id]WHERE

which will give a VBA error.
 
thanks

Thank mile and houstontx. appreciated your prompt respond.

Dianna
 

Users who are viewing this thread

Back
Top Bottom