Finding and updating records

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
 
P

PC Datasheet

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
 
G

Guest

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.
 
G

Guest

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
 
L

LGC

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top