runtime error '3078'

sbooth

Registered User.
Local time
Today, 17:51
Joined
Mar 16, 2008
Messages
35
I have frmEntry with control HorseNum_fk. The user types in a horse's name. If the horse is not in the table, I want the frmHorse to popup with the horse name the user just entered. After entering further information, when the user clicks on the close button at the bottom of the field, the horse's name should be in the frmEntry allowing the user to go on to the next field.

I have done the following code:

In frmEntry On Not In List event
Code:
Private Sub HorseNum_fk_NotInList(NewData As String, Response As Integer)

    Dim Result
    Dim Msg As String
    Dim CR As String
    
        CR = Chr$(13)
        
        'Exit This subroutine if the combox box was cleared.
        If NewData = "" Then Exit Sub
        'Ask the user if he or she wishes to add a new horse.
        Msg = "'" & NewData & "' is not in the list." & CR & CR
        Msg = Msg & "Do you want to add it?"
        If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
            'If the user chose Yes, start the New Horse form in data entry
            'mode as a dialog form, passing the new horse name in
            'NewData to the OpenForm method's OpenArgs argument.  The
            'Open Args argument is used in New Horse form's Form_Load event
            'procedure.
            DoCmd.OpenForm "frmHorse", , , , acAdd, acDialog, NewData
        End If
        
        'Look for the horse the user created in the New Horse form.
        Result = DLookup("[HorseName]", "frmHorse", "[HorseName]='" & NewData & "'")
        
        If IsNull(Result) Then
            'If the horse was not created, set the Response argument
            'to suppress an error message and undo changes.
            Response = acDataErrContinue
            'Display a customized message.
            MsgBox "Please try again!"
        Else
            'If the horse was created, set the Response argument to
            'indicate that the new data is being added.
            Response = acDataErrAdded
        End If
    
End Sub

In frmHorse On Load event
Code:
Private Sub Form_Load()
    If Not IsNull(Me.OpenArgs) Then
    'If form's OpenArgs property has a value, assign the contents
    'of Open Args to the HorseName field.  OpenArgs will contain
    'a horse name if this form is opened using the OpenForm
    'method with an OpenArgs argument, as done in the Events
    'form's HorseNum_fk_NotInList event procedure.
    Me![HorseName] = Me.OpenArgs
    End If
End Sub

When I click tab after entering a horse who is not in the table, the frmHorse opens. The data name I entered in frmEntry is in frmHorse. I click on the close button at the bottom of frmHorse and get
run-time error '3078'
The microsoft Jet database engine cannot find the input table or query 'frmHorse'. Make sure it exists and that its name is spelled correctly.

I click on debug and

Code:
Result = DLookup("[HorseName]", "frmHorse", "[HorseName]='" & NewData & "'")

is the problem. Can anyone help me with the syntax?
 
I have frmEntry with control HorseNum_fk. The user types in a horse's name. If the horse is not in the table, I want the frmHorse to popup with the horse name the user just entered. After entering further information, when the user clicks on the close button at the bottom of the field, the horse's name should be in the frmEntry allowing the user to go on to the next field.

I have done the following code:

In frmEntry On Not In List event
Code:
Private Sub HorseNum_fk_NotInList(NewData As String, Response As Integer)

    Dim Result
    Dim Msg As String
    Dim CR As String
    
        CR = Chr$(13)
        
        'Exit This subroutine if the combox box was cleared.
        If NewData = "" Then Exit Sub
        'Ask the user if he or she wishes to add a new horse.
        Msg = "'" & NewData & "' is not in the list." & CR & CR
        Msg = Msg & "Do you want to add it?"
        If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
            'If the user chose Yes, start the New Horse form in data entry
            'mode as a dialog form, passing the new horse name in
            'NewData to the OpenForm method's OpenArgs argument.  The
            'Open Args argument is used in New Horse form's Form_Load event
            'procedure.
            DoCmd.OpenForm "frmHorse", , , , acAdd, acDialog, NewData
        End If
        
        'Look for the horse the user created in the New Horse form.
        Result = DLookup("[HorseName]", "frmHorse", "[HorseName]='" & NewData & "'")
        
        If IsNull(Result) Then
            'If the horse was not created, set the Response argument
            'to suppress an error message and undo changes.
            Response = acDataErrContinue
            'Display a customized message.
            MsgBox "Please try again!"
        Else
            'If the horse was created, set the Response argument to
            'indicate that the new data is being added.
            Response = acDataErrAdded
        End If
    
End Sub

In frmHorse On Load event
Code:
Private Sub Form_Load()
    If Not IsNull(Me.OpenArgs) Then
    'If form's OpenArgs property has a value, assign the contents
    'of Open Args to the HorseName field.  OpenArgs will contain
    'a horse name if this form is opened using the OpenForm
    'method with an OpenArgs argument, as done in the Events
    'form's HorseNum_fk_NotInList event procedure.
    Me![HorseName] = Me.OpenArgs
    End If
End Sub

When I click tab after entering a horse who is not in the table, the frmHorse opens. The data name I entered in frmEntry is in frmHorse. I click on the close button at the bottom of frmHorse and get


I click on debug and

Code:
Result = DLookup("[HorseName]", "frmHorse", "[HorseName]='" & NewData & "'")

is the problem. Can anyone help me with the syntax?
DLOOkup only works on a table or a query. frmHorse looks like it is a form. Thats why it is'nt working for you. The data just entered will be in Forms.frmHorse.Horsename so there is no need to do a Dlookup.
 
Thanks Rabbie. I used
Response=acDataErrAdded
and that fixed the problem.
 

Users who are viewing this thread

Back
Top Bottom