B
Brad
Thanks for taking the time to read my question.
I have a form that has a text box (Name) and a list box (List of all Names).
The rowsource for the Listbox is a query of the tblTest described below.
The form that these are on is based on tblTest.
As the user moves through the records, I would like the Name in the Current
Record to be hilighted in the Listbox.
I can accomplish this, but when I try to move to the next record I get this
error, and no err.number. When I hit Esc, I can move to the next record.
Then when I try to move again, I get the error again.
Error:
"Update or CancelUpdate without AddNew or Edit." (OK Help)
here is my code.
Private Sub Form_Current()
Dim dbs As Database, rst As Recordset, qdf As QueryDef
Dim x As Integer
On Error GoTo Form_Current_Err
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("Query1")
Set rst = qdf.OpenRecordset()
x = 0
If Me.NewRecord Then
Exit Sub
Else
If Not rst.EOF Then
rst.MoveFirst
Do Until rst!TestID = Me.TestID Or rst.EOF
x = x + 1
rst.MoveNext
Loop
Me.NameList.Selected(x) = True
End If
End If
rst.Close
qdf.Close
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
Form_Current_Err_Res:
Exit Sub
Form_Current_Err:
MsgBox Err.Number
Resume Form_Current_Err_Res
End Sub
The SQL for my query:
SELECT DISTINCTROW tblTest.TestID, tblTest.Name
FROM tblTest
ORDER BY tblTest.Name;
I have one table called tblTest and it has 2 fields TextID (autonum) and
Name (Text)
How do I stop this error?
Thanks again,
Brad
I have a form that has a text box (Name) and a list box (List of all Names).
The rowsource for the Listbox is a query of the tblTest described below.
The form that these are on is based on tblTest.
As the user moves through the records, I would like the Name in the Current
Record to be hilighted in the Listbox.
I can accomplish this, but when I try to move to the next record I get this
error, and no err.number. When I hit Esc, I can move to the next record.
Then when I try to move again, I get the error again.
Error:
"Update or CancelUpdate without AddNew or Edit." (OK Help)
here is my code.
Private Sub Form_Current()
Dim dbs As Database, rst As Recordset, qdf As QueryDef
Dim x As Integer
On Error GoTo Form_Current_Err
Set dbs = CurrentDb
Set qdf = dbs.QueryDefs("Query1")
Set rst = qdf.OpenRecordset()
x = 0
If Me.NewRecord Then
Exit Sub
Else
If Not rst.EOF Then
rst.MoveFirst
Do Until rst!TestID = Me.TestID Or rst.EOF
x = x + 1
rst.MoveNext
Loop
Me.NameList.Selected(x) = True
End If
End If
rst.Close
qdf.Close
Set rst = Nothing
Set qdf = Nothing
Set dbs = Nothing
Form_Current_Err_Res:
Exit Sub
Form_Current_Err:
MsgBox Err.Number
Resume Form_Current_Err_Res
End Sub
The SQL for my query:
SELECT DISTINCTROW tblTest.TestID, tblTest.Name
FROM tblTest
ORDER BY tblTest.Name;
I have one table called tblTest and it has 2 fields TextID (autonum) and
Name (Text)
How do I stop this error?
Thanks again,
Brad