H
Hoppy
Hello, I'm just learning Access programming and I wrote a database for our
office. It works fine except for one combo box on one of the forms. The
combo box DOES work on my home PC which is where I worked on this one form.
But it DOESN'T work when I install the form in the database at my office! At
work the database resides on our server and at home it's just on my PC. I've
been working on this for two weeks and can't figure out the problem. Would
appreciate any help.
There isn't an error message but the program opens up the VBA procedure and
it's highlighted with YELLOW. There's no clues as to why it stopped there.
I have the combo box Limit to List set to YES
I have the RecordSource Type set to Table/Query
The RowSource is set to COMPANYTABLE Query (it sorts Company Names
Alphabetically)
The database has TWO tables one table just for CompanyNames with one field
"Company Name"
The other table has the same field "Company Name" but also contains numerous
other fields not involved in this procedure.
The name of the combo box is "Company"
When a user enters a company that isn't on the list I want a message box to
open asking if they want to add it. If they select Yes the name is added to
the table "COMPANYTABLE" and that's it. The table gets the name sorts it
into the list of names.
Here's the code I copied from the procedure, the error occurs at the
db.Execute "INSERT INTO [COMPANYTABLE] ([COMPANY NAME]) VALUES (""" & NewData
& """)", dbFailOnError
Private Sub COMPANY_NotInList(NewData As String, Response As Integer)
Dim db As Database
Set db = CurrentDb
Response = False
Me.COMPANY = Null
msg = "The company: " & Chr(13) & Chr(13) & NewData & Chr(13) & Chr(13)
msg = msg & "is not in the list. Do you want to add it?"
typ = vbExclamation + vbYesNo
ttl = "New Item"
resp = MsgBox(msg, typ, ttl)
If resp = vbNo Then
Me.COMPANY.Undo
Response = acDataErrContinue
Else
db.Execute "INSERT INTO [COMPANYTABLE] ([COMPANY NAME]) VALUES (""" &
NewData & """)", dbFailOnError
Me.COMPANY.Requery
Me.COMPANY = NewData
Response = acDataErrAdded
End If
End Sub
Any suggestions would be very much appreciated! I have the same program on
my PC that we have at work Access 2003. However, there are permissions and
things on the database at work. Thanks in advance for any help! Let me know
if anyone needs more information.
office. It works fine except for one combo box on one of the forms. The
combo box DOES work on my home PC which is where I worked on this one form.
But it DOESN'T work when I install the form in the database at my office! At
work the database resides on our server and at home it's just on my PC. I've
been working on this for two weeks and can't figure out the problem. Would
appreciate any help.
There isn't an error message but the program opens up the VBA procedure and
it's highlighted with YELLOW. There's no clues as to why it stopped there.
I have the combo box Limit to List set to YES
I have the RecordSource Type set to Table/Query
The RowSource is set to COMPANYTABLE Query (it sorts Company Names
Alphabetically)
The database has TWO tables one table just for CompanyNames with one field
"Company Name"
The other table has the same field "Company Name" but also contains numerous
other fields not involved in this procedure.
The name of the combo box is "Company"
When a user enters a company that isn't on the list I want a message box to
open asking if they want to add it. If they select Yes the name is added to
the table "COMPANYTABLE" and that's it. The table gets the name sorts it
into the list of names.
Here's the code I copied from the procedure, the error occurs at the
db.Execute "INSERT INTO [COMPANYTABLE] ([COMPANY NAME]) VALUES (""" & NewData
& """)", dbFailOnError
Private Sub COMPANY_NotInList(NewData As String, Response As Integer)
Dim db As Database
Set db = CurrentDb
Response = False
Me.COMPANY = Null
msg = "The company: " & Chr(13) & Chr(13) & NewData & Chr(13) & Chr(13)
msg = msg & "is not in the list. Do you want to add it?"
typ = vbExclamation + vbYesNo
ttl = "New Item"
resp = MsgBox(msg, typ, ttl)
If resp = vbNo Then
Me.COMPANY.Undo
Response = acDataErrContinue
Else
db.Execute "INSERT INTO [COMPANYTABLE] ([COMPANY NAME]) VALUES (""" &
NewData & """)", dbFailOnError
Me.COMPANY.Requery
Me.COMPANY = NewData
Response = acDataErrAdded
End If
End Sub
Any suggestions would be very much appreciated! I have the same program on
my PC that we have at work Access 2003. However, there are permissions and
things on the database at work. Thanks in advance for any help! Let me know
if anyone needs more information.