Finding and updating records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to find a specific record based on input from a text box on a
form. The user would hit a command button then the record would be updated.
I keep getting a data type mismatch error. This seems like it should be very
straight foward, but I am hitting a wall. Please help.


Set dbATTRAC = CurrentDb
Set rsAW_Data = dbATTRAC.OpenRecordset("AW_Data", dbOpenDynaset)


With rsAW_Data
.FindFirst "SSAN = " & txtSSAN.Text
If rsAW_Data("SSAN") = txtSSAN.Text then
'Update code here
End If
End With

TIA
 
Your code says that you want to update the field, SSAN, programatically
rather than by changing the value in your form; is that what you want to do?

Change this:
If rsAW_Data("SSAN") = txtSSAN.Text then
'Update code here
End If

To This:
If rsAW_Data.NoMatch = False Then
'Update code here
End If
 
Yes that is what I want to do. I am still getting the data type mismatch
error after I made the change. Thanks for the help.
 
right now if the record matches all I want to is pop up a message box. Also
I have a do while loop that goes until the EOF, if there is a way to get out
of this loop once a condition is met but before EOF that would be helpful
also.

Private Sub cmdSignIn_Click()
On Error GoTo Err_cmdSignIn_Click
txtSSAN.SetFocus





Set dbATTRAC = CurrentDb
Set rsAW_Data = dbATTRAC.OpenRecordset("AW_Data", dbOpenDynaset)





With rsAW_Data
.FindFirst "rsAW_Data!SSAN] = " & txtSSAN.Value
If rsAW_Data.NoMatch = False Then
MsgBox "yes"
End If
End With
 
right now if the record matches all I want to is pop up a message box.
Also
I have a do while loop that goes until the EOF, if there is a way to get out
of this loop once a condition is met but before EOF that would be helpful
also.

Exit Do

-LGC
 
Back
Top