J
Joseph Atie
I have a piece of code that checks a table to see if a record already exists
before it allows a form to pass its data on to the next form in the chain
pretty simple stuff. It works on several other forms, but for some reason
one form keeps throwing errors at me. Im sure its pretty something small but
i cant seem to find what is wrong with the code
HELP PLEASE
Private Sub Command7_Click()
'declaration
Dim fname As String
Dim sname As String
Dim rs As Recordset
Dim rstr As String
Dim answer As Boolean
'initilisation
fname = text1.Value
sname = eType.Value
rstr = "SELECT Users.[First Name], Users.Surname FROM Users WHERE
Users.[First Name]=" & fname & " AND Users.Surname= " & sname & ";"
Set rs = CurrentDb.OpenRecordset(rstr)
'begin data checking
rs.MoveLast
If rs.RecordCount < 1 Then
DoCmd.OpenForm "user_add_3", acNormal, , , acFormAdd, acWindowNormal
DoCmd.Close acForm, "user_add_2", acSaveNo
Forms!user_add_3.Label14.Value = fname
Else
answer = MsgBox("This User is already in the system, Please try again",
vbYesNo, "Existing User")
If answer = True Then
DoCmd.OpenForm "user_add_1", acNormal, , , acFormAdd, acWindowNormal
DoCmd.Close acForm, "user_add_2", acSaveNo
Forms!user_add_3.Label14.Value = fname
Else
DoCmd.OpenForm "main_menu", acNormal, , , acFormAdd, acWindowNormal
DoCmd.Close acForm, "user_add_2", acSaveNo
End If
End If
End Sub
before it allows a form to pass its data on to the next form in the chain
pretty simple stuff. It works on several other forms, but for some reason
one form keeps throwing errors at me. Im sure its pretty something small but
i cant seem to find what is wrong with the code
HELP PLEASE
Private Sub Command7_Click()
'declaration
Dim fname As String
Dim sname As String
Dim rs As Recordset
Dim rstr As String
Dim answer As Boolean
'initilisation
fname = text1.Value
sname = eType.Value
rstr = "SELECT Users.[First Name], Users.Surname FROM Users WHERE
Users.[First Name]=" & fname & " AND Users.Surname= " & sname & ";"
Set rs = CurrentDb.OpenRecordset(rstr)
'begin data checking
rs.MoveLast
If rs.RecordCount < 1 Then
DoCmd.OpenForm "user_add_3", acNormal, , , acFormAdd, acWindowNormal
DoCmd.Close acForm, "user_add_2", acSaveNo
Forms!user_add_3.Label14.Value = fname
Else
answer = MsgBox("This User is already in the system, Please try again",
vbYesNo, "Existing User")
If answer = True Then
DoCmd.OpenForm "user_add_1", acNormal, , , acFormAdd, acWindowNormal
DoCmd.Close acForm, "user_add_2", acSaveNo
Forms!user_add_3.Label14.Value = fname
Else
DoCmd.OpenForm "main_menu", acNormal, , , acFormAdd, acWindowNormal
DoCmd.Close acForm, "user_add_2", acSaveNo
End If
End If
End Sub