psbsmms
Programmer
- Dec 14, 2001
- 74
I get this problem off and on and I'm hoping someone can tell me what I am doing wrong. I have a form or control that is working fine and then while add more code, usaually something to handle something I didn't anticipate the user doing. My current issue is between two combo boxes. I have one box that they select a store number and on lost focus I set the rowsource of the second combo box to a sql string. it was working fine until a user forgot to put a store number in the 1st box. I went back and had the event look for a null value and exit sub on finding it. Now it doesn't populate the other combo box and when i put a stop in to check the code the debugger loops between the first line and stop and goes no further. As I said this has happebed several times to me on other controls, and I've had to remake the entire form to make it work. I have even sometimes been able to copy the code from one form to the other to save typing and it works. This one is driving me crazy. I am using A2k and XP pro.
The latest code that is giving me the error is below.
Private Sub cmbStore_LostFocus()
Dim strStoreNo As String
Dim intID As Integer
Dim strSQL As String
Dim DB As DAO.Database
Dim RS As DAO.Recordset
Stop
If IsNull(cmbStore.Value) Then
MsgBox "You entered and ivalid number for store please try again", vbOKOnly
Exit Sub
End If
strStoreNo = cmbStore.Column(0)
strSQL = "Select [tbljobs].[id], [tbljobs].[JobNo] from [tbljobs] where [StoreNo] = '" & strStoreNo & "';"
Set DB = CurrentDb
Set RS = DB.OpenRecordset(strSQL)
If RS.RecordCount < 1 Then
MsgBox "You have entered a store number that has no listed jobs", vbOKOnly
Exit Sub
Else: cmbJobSelected.RowSource = strSQL
End If
End Sub
The latest code that is giving me the error is below.
Private Sub cmbStore_LostFocus()
Dim strStoreNo As String
Dim intID As Integer
Dim strSQL As String
Dim DB As DAO.Database
Dim RS As DAO.Recordset
Stop
If IsNull(cmbStore.Value) Then
MsgBox "You entered and ivalid number for store please try again", vbOKOnly
Exit Sub
End If
strStoreNo = cmbStore.Column(0)
strSQL = "Select [tbljobs].[id], [tbljobs].[JobNo] from [tbljobs] where [StoreNo] = '" & strStoreNo & "';"
Set DB = CurrentDb
Set RS = DB.OpenRecordset(strSQL)
If RS.RecordCount < 1 Then
MsgBox "You have entered a store number that has no listed jobs", vbOKOnly
Exit Sub
Else: cmbJobSelected.RowSource = strSQL
End If
End Sub