spilwayboy
Registered User.
- Local time
- Today, 02:25
- 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
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: