Emilio,
<<How do I determine if it is a new record?>>
The form has a NewRecord property, which you can test:
If Me.NewRecord = False Then
'run the query
End
<<What would trigger the query to run?>>
Whatever trigger you like. I'd suggest the form's BeforeInsert or
AfterInsert events.
<<How can I make sure all the four fields have been populated?>>
Run code to make sure.
Private Sub Form_AfterInsert()
Dim sSQL As String
If (Me.NewRecord = False) Then
'Check that the 4 fields have been populated
If Not IsNull(Me.txtTextbox1) AND _
Not IsNull(Me.txtTextbox2) AND _
Not IsNull(Me.txtTextbox3) AND _
Not IsNull(Me.txtTextbox4) Then
sSQL = "INSERT INTO tblSomeTable.........."
DbEngine(0)(0).Execute sSQL, dbFailOnError
If (Err <> 0) Then
MsgBox Error " & Err.Number & vbCrLf & Err.Description
End If
Else
MsgBox "You must enter a value in the 4 textboxes"
End If
End
End Sub
If you give me the specifics, I can help you develop the SQL statement.
Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html