G
Guest
I'm trying to offer the user the option to enter a new record from the
OnNotInList event. Sinc the source table has more than one field, I want to
present a popup form, let them enter the new record, and requery the combo
box on closing the form.
The code below passes NewData as the OpenArgs parameter of the OpenForm
method, but triggers the error, "You can't assign a value to this object." on
the line assigning the txtProjectName control.
Can anyone tell me what I'm doing wrong?
Thanks.
Sprinks
' Combo Box Code
Private Sub cboProjectNumber_NotInList(NewData As String, Response As Integer)
Dim intx As Integer
Response = acDataErrContinue
intx = MsgBox(NewData & " has not yet been added. " & _
"Add it now?", vbYesNo, "Project Not Found")
If intx = vbNo Then
Response = acDataErrDisplay
Else
DoCmd.OpenForm "Projects", acNormal, , , acFormAdd, acDialog, NewData
DoCmd.Save
Me!cboProjectNumber.Requery
End If
End Sub
' Popup form code
Private Sub Form_Open(Cancel As Integer)
If Not IsNull(OpenArgs) Then
Me!txtProjectName = OpenArgs
Me!txtProjectNumber.SetFocus
End If
End Sub
OnNotInList event. Sinc the source table has more than one field, I want to
present a popup form, let them enter the new record, and requery the combo
box on closing the form.
The code below passes NewData as the OpenArgs parameter of the OpenForm
method, but triggers the error, "You can't assign a value to this object." on
the line assigning the txtProjectName control.
Can anyone tell me what I'm doing wrong?
Thanks.
Sprinks
' Combo Box Code
Private Sub cboProjectNumber_NotInList(NewData As String, Response As Integer)
Dim intx As Integer
Response = acDataErrContinue
intx = MsgBox(NewData & " has not yet been added. " & _
"Add it now?", vbYesNo, "Project Not Found")
If intx = vbNo Then
Response = acDataErrDisplay
Else
DoCmd.OpenForm "Projects", acNormal, , , acFormAdd, acDialog, NewData
DoCmd.Save
Me!cboProjectNumber.Requery
End If
End Sub
' Popup form code
Private Sub Form_Open(Cancel As Integer)
If Not IsNull(OpenArgs) Then
Me!txtProjectName = OpenArgs
Me!txtProjectNumber.SetFocus
End If
End Sub