Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / January 2005

Tip: Looking for answers? Try searching our database.

Err Msg Prob

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brad - 11 Jan 2005 16:39 GMT
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
Brad - 11 Jan 2005 16:49 GMT
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

> Thanks for taking the time to read my question.
>
[quoted text clipped - 69 lines]
>
> Brad
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.