Combo box problem

spilwayboy

Registered User.
Local time
Today, 00:56
Joined
Dec 17, 2002
Messages
17
thanks in advance to all of those who reply. I have a project that I am putting together a historical index of equipment quotations and have a form that has a combo box linking to a seperate table from what the form is based on. the combo box looks up the project numbers that we used the quotation on from a different table that is linked by a one to many relationship between the two tables. I set the not in list property to yes and posted the code below into the not in list property, but when the code runs I get an error message and I am not good enough at VB yet to knoe what it means, but it says "User defined type not defined" This is the code.

Sub Combo32_NotInList(NewData As String, Response As Integer)

Dim DB As Database
Dim RS As Recordset
Dim Msg As String
Dim CR As String: CR = Chr$(13)

' Exit Sub if the user cleared the selection.
If NewData = "" Then Exit Sub

' Ask if the user wants to add the new reference job number.
Msg = "'" & NewData & "' is not in the list." & CR & CR
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, 32 + 4) = 7 Then
' If the user chooses No, instruct the user to try again.
Response = DATA_ERRCONTINUE
MsgBox "Please try again."
Else
' If the user does not choose No, create a new record in the
' Customer table.
On Error Resume Next

' Open the Customer table.
Set DB = DBEngine.Workspaces(0).Databases(0)
Set RS = DB.OpenRecordset("tblEquipRefonProjects", DB_OPEN_DYNASET)

RS.AddNew
RS![strRefProjectNum] = NewData
RS.Update
' If an error occurred while adding the record...
If Err Then
' ...instruct the user to try again.
Response = DATA_ERRCONTINUE
Beep: MsgBox Error$, 48
MsgBox "Please try again."
Else
' If no error occurred, add the element to the combo box
' list.
Response = DATA_ERRADDED
End If

End If
End Sub

Any help is appreciated.

Thanks,
Spil
 
Last edited:
Which line does this error occur on?
 
How would I find this out ? I think it is on the first line that says "Dim db as database" I seem to remember it breaking on that line and opening the debugger with that part highlighted. If I can find out for oyu plase let me know how.

Thanks,
Spil
 
Place a Breakpoint on this line:

Sub Combo32_NotInList(NewData As String, Response As Integer)

then use the F8 Key to step through the code.
 
I placed the break point and did the F8 thing and it broke on the first line "Dim db as database" and it breaks on "as database". Could this be a wrong variable callout. That one and the one underneath it do not turn blue after the as like the rest of them which leads me to believ it is wrong but it is not red like other things that I have typed wrong.

Thanks,
Spil
 
Last edited:
It is a Reference Issue. Make sure you have the DAO 3.6 Reference in your DB
 

Users who are viewing this thread

Back
Top Bottom