RE: Err Msg Prob

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Brad (Brad_at_discussions.microsoft.com)
Date: 01/11/05


Date: Tue, 11 Jan 2005 08:49:04 -0800

One note to add...

I just clicked in the listbox and moved from record to record without error.
 It must be something to do with the text box. I have no code on it though.

Brad

"Brad" wrote:

> 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



Relevant Pages

  • Re: Populate Data Entry Form through listbox
    ... To read the rows selected in a multi-select listbox, ... 'or set rst = Forms!.RecordsetClone ... > on a data entry form with the values from column 1 in the listbox. ...
    (microsoft.public.access.forms)
  • Re: Add Items From List Box To Table
    ... I would envisage this as first create the records in the table based on the selections in the listbox, and then open a form whose recordsource is the newly created records for the user to fill in the rest of the fields. ... Set rst = db.OpenRecordset ... scroll down to find Microsoft DAO 3.6 Object Library reference and check it. ... the selected items to the record source. ...
    (microsoft.public.access.formscoding)
  • Re: Problem with multiselect list box code
    ... Set rst = db.OpenRecordset ... of the listbox but seperate fields on the form EventID & ... Dim frm As Form, ctl As Control ... Dim varItem As Variant ...
    (microsoft.public.access.formscoding)
  • Re: Need help binding multiselect listbox to table
    ... The fields which the listbox holds ... DateSubmitted and SubmitAuthorizedBy fields with the contents of the ... MsgBox "No items selected. ... Set rst = db.OpenRecordset ...
    (comp.databases.ms-access)
  • Err Msg Prob
    ... The rowsource for the Listbox is a query of the tblTest described below. ... Exit Sub ...
    (microsoft.public.access.formscoding)