I am using Microsoft Access 2000.
The code below resides in a subform. Using the DMax command, strRevisionDate is loaded with the largest TDateRevised value that can be found in tblTDateRevision for a given Project Number. The SQL statement then updates the field SupervisorTDateRevised (found in tblProjectMain) using the value in strRevisionDate. The project number comes from the mainform [Forms]![frmAddProjTDateRevMain]![ProjectNumber].
The problem with the code occurs after the user hits a command button to save data entered on the screen. An “Enter Parameter Value” dialog box pops up asking for a value for strRevisionDate associated with the SET part of the SQL statement. If the user supplies the date, the code executes and makes the proper update.
I have displayed the component fields involved in the code to make sure that each had its proper value and found everything to be OK. I have also defined strRevisedDate as a Date field but encountered the same results.
The only time I don't get the Enter Parameter Value box is when I remove strRevisedDate from the SET and hard-code a date (like '05/20/2006') in its place. Then everything works fine.
Why is the dialog box appearing? And how can I make it not appear but still have the code execute successfully?
Much thanks in advance,
Rooski
The code below resides in a subform. Using the DMax command, strRevisionDate is loaded with the largest TDateRevised value that can be found in tblTDateRevision for a given Project Number. The SQL statement then updates the field SupervisorTDateRevised (found in tblProjectMain) using the value in strRevisionDate. The project number comes from the mainform [Forms]![frmAddProjTDateRevMain]![ProjectNumber].
The problem with the code occurs after the user hits a command button to save data entered on the screen. An “Enter Parameter Value” dialog box pops up asking for a value for strRevisionDate associated with the SET part of the SQL statement. If the user supplies the date, the code executes and makes the proper update.
I have displayed the component fields involved in the code to make sure that each had its proper value and found everything to be OK. I have also defined strRevisedDate as a Date field but encountered the same results.
The only time I don't get the Enter Parameter Value box is when I remove strRevisedDate from the SET and hard-code a date (like '05/20/2006') in its place. Then everything works fine.
Why is the dialog box appearing? And how can I make it not appear but still have the code execute successfully?
Code:
Private Sub Form_AfterUpdate()
Dim strRevisionDate As String
Dim strSQL As String
strRevisionDate = ""
strSQL = ""
strRevisionDate = DMax("[TDateRevised]", "tblTDateRevision", "[ProjectNumber] =" & "[Forms]![frmAddProjTDateRevMain]![ProjectNumber]")
strSQL = "UPDATE tblProjectMain " & "SET [SupervisorTDateRevised] = strRevisionDate " & "WHERE [ProjectNumber] = [Forms]![frmAddProjTDateRevMain]![ProjectNumber];"
DoCmd.RunSQL strSQL
End Sub
Much thanks in advance,
Rooski