sql select

R

Russ

I need to select a record with a SQL, which will execute when i click a
button. the field SSN is in the main form, the field DateOfVisit is in a
subform (which is on a tab within the main form). i have tried the follwing
but have been unsuccessful.

If DCount("[SSN]", "New_Visit", "[SSN] ='" & Me.SSN & "'") > 0 Then
Dim strnewvisitSQL
strnewvisitSQL = "UPDATE [New_Visit] SET [TimeStamp] = Now()" & " WHERE
DateOfVisit =#" & Me.New_Patient_Entry_Subform.DateOfVisit.value & "# AND SSN
= '" & Me.SSN.value & "';"
CurrentDb.Execute strallerSQL, dbFailOnError
End If

it works fine if i take out the part with the dateofvisit, but i need to
only chnage the timestamp for the specified dateofvisit. anyhelp is
appreciated.

thank you
russ
 
D

Duane Hookom

You don't seem to be running the sql statement you just created.
You need to learn how to debug/troubleshoot your code. Modify your code to
read:
If DCount("[SSN]", "New_Visit", "[SSN] ='" & Me.SSN & "'") > 0 Then
Dim strnewvisitSQL
strnewvisitSQL = "UPDATE [New_Visit] SET [TimeStamp] = Now()" & _
" WHERE DateOfVisit =#" & _
Me.New_Patient_Entry_Subform.DateOfVisit.value & _
"# AND SSN = '" & Me.SSN.value & "';"
Debug.Print strNewVisitSQL
CurrentDb.Execute strallerSQL, dbFailOnError
End If
 
Top