Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

moving thru a record set

Status
Not open for further replies.

grmman

MIS
Sep 9, 2003
81
US
I am try to trap to make sure the user filled in all the fields that are req.
So I did an check on the next button to do a query on the table to check to see if there is any null values.

It looks like it works the frist time but then after it dosent

Can someone look at my code and see if I am doing something dumb.
Thanks for the help
Code:
Private Sub cmdnext_Click()
On Error GoTo Err_cmdnext_Click
Dim strloanid As String
Dim strreg As String
Dim dbs As Database
Dim rst As Recordset
Dim strsql As String

strloanid = Me.LoanID.Value
strreg = Me.ModName.Value
Set dbs = CurrentDb()

strsql = "select * from tblresults where LoanID =  " & " '" & strloanid & "'" & " And ModName = " & " '" & strreg & "'" & " and answer IS NULL"

' MsgBox strsql

Set rst = dbs.OpenRecordset(strsql)

'Set rst = dbs.OpenRecordset("qry_search_ans")
 'rst.MoveFirst
 'rst.MoveLast
'If rst.RecordCount <> 0 Then
 '  MsgBox rst.RecordCount
'End If
If rst.EOF Then
        DoCmd.GoToRecord , , acNext
Else

'    rst.MoveLast
 '   rst.MoveFirst
  '  If rst.RecordCount > 0 Then
        MsgBox "Please check all answers to make sure you have answered all the questions"
                  
   ' End If

End If

rst.Close
Set dbs = Nothing
Set rst = Nothing
    

Exit_cmdnext_Click:
    Exit Sub

Err_cmdnext_Click:
    MsgBox Err.Description
    Resume Exit_cmdnext_Click
    
End Sub

 
A classical way to enforce rules is to play with the BeforeUpdate event procedure of the form.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top