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 / May 2007

Tip: Looking for answers? Try searching our database.

Add Item to Combo Box Using OnNotinList Event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert - 06 May 2007 19:52 GMT
I am working with the example code written by Dev Ashish from The Access Web
site and I have run into a brick wall.

I am trying to debug the following line:
Set rs = db.OpenRecordset("City (table) Query", dbOpenDynaset)
When I run the test the following error message pops up:
An error occurred.  Please try again.
No other information is provided.

The following is the code sequence that I have at this time:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub City_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String

   strMsg = "'" & NewData & "' is not an available City Name " & vbCrLf &
vbCrLf
   strMsg = strMsg & "Do you want to associate the new Name to the current
DLSAF?"
   strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to link or No to re-type
it."
   
   If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
       Response = acDataErrContinue
   Else
       Set db = CurrentDb
       Set rs = db.OpenRecordset("City (table) Query", dbOpenDynaset)
       On Error Resume Next
       rs.AddNew
           rs!CityName = NewData
       rs.Update
       
       If Err Then
           MsgBox "An error occurred. Please try again."
           Response = acDataErrContinue
       Else
           Response = acDataErrAdded
       End If
       
   End If

rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Any assistance that can be offered will be greatly appreciated.

Signature

Robert

Maurice - 06 May 2007 20:19 GMT
Robert,

What is the name of the table, is it really City(Table)Query?

My guess is that you should only name the referring table as your source so
it could be something like this: Set rs = db.OpenRecordset("City",
dbOpenDynaset)

If it's a query you are using choose that name. If neither is the case try
renaming the source without the brackets.

Maurice

> I am working with the example code written by Dev Ashish from The Access Web
> site and I have run into a brick wall.
[quoted text clipped - 45 lines]
>
> Any assistance that can be offered will be greatly appreciated.
Robert - 06 May 2007 20:36 GMT
Maurice,

Thank you for responding.

The actual name of the query is "City (table) Query", additionally the name
of the table is City (table).  Either way I get the same result.

If I remove the "()" the message error changes to a Run-time error '3078',
The Microsoft Jet database engine cannot find the input table or query "City
table" in this case.  Make sure it exists and that its name is spelled
correctly.

I am unable to reach beyond these two issues.
Signature

Robert

> Robert,
>
[quoted text clipped - 58 lines]
> >
> > Any assistance that can be offered will be greatly appreciated.
Douglas J. Steele - 06 May 2007 20:43 GMT
When you have embedded spaces or special characters, you need to enclose the
table or field name in square brackets.

      Set rs = db.OpenRecordset("[City (table) Query]", dbOpenDynaset)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Maurice,
>
[quoted text clipped - 81 lines]
>> >
>> > Any assistance that can be offered will be greatly appreciated.
Robert - 06 May 2007 20:52 GMT
Douglas,

Thanks for responding.

I just tried that again and again received the Run-time error '3078' as
decribed below.
Signature

Robert

> When you have embedded spaces or special characters, you need to enclose the
> table or field name in square brackets.
[quoted text clipped - 86 lines]
> >> >
> >> > Any assistance that can be offered will be greatly appreciated.
Ofer Cohen - 06 May 2007 21:58 GMT
I tried it and I got the same error, I stop getting it when I wrote the full
select

Set rs = db.OpenRecordset("Select * From [City (table) Query]", dbOpenDynaset)

Note: make sure that the table name is still the same

Signature

Good Luck
BS"D

> Douglas,
>
[quoted text clipped - 93 lines]
> > >> >
> > >> > Any assistance that can be offered will be greatly appreciated.
Maurice - 07 May 2007 08:41 GMT
Robert,

Ofer has just given you a resolution to your problem but I still want to
point out to you the fact that the name of the table is not all that
workable. I know it might be that you got the structure of someone else but
if it is your design please reconsider renaming the table. My guess would be
that it won't be the last time you will bump into brackets, semicolons atc..

Mauirce

> I tried it and I got the same error, I stop getting it when I wrote the full
> select
[quoted text clipped - 100 lines]
> > > >> >
> > > >> > Any assistance that can be offered will be greatly appreciated.
 
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.