Object Reuired error

Z

zufie

When I click the Command Button to open a form I receive the error:
Object Reuired.

This form is a subform connected to a main form.

Any suggestions?

Thanks!

Zuf

Here is the code behind the Command Button:

Private Sub Command108_Click()
On Error GoTo Err_Command108_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmQuery5"

' stLinkCriteria = "[CallDate] Between [Forms]![Main]![Child89].
[Form]![txtBeginQAEvry5th] And [Forms]![Main]![Child89].[Form]!
[txtEndQAStopEvry5th]"
stLinkCriteria = "[CallDate] Between #" & txtBeginQAEvry5th.Value
& "# and #" & txtEndQAStopEvry5th.Value & "#"

DoCmd.OPENFORM stDocName, acNormal, , stLinkCriteria, acFormEdit

Exit_Command108_Click:
Exit Sub

Err_Command108_Click:
MsgBox Err.Description
Resume Exit_Command108_Click

End Sub
 
J

John Spencer

Try the following

stLinkCriteria = "[CallDate] Between #" &
[Forms]![Main]![Child89].[Form]![txtBeginQAEvry5th] & "# And #" &
[Forms]![Main]![Child89].[Form]![txtEndQAStopEvry5th] & "#"

'Temporary debug code.
Debug.Print stLinkCriteria
Stop 'Look at the immediate window
'and see if stLinkCriteria is properly formed
'if so continue the code and check the result.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
Z

zufie

Try the following

  stLinkCriteria = "[CallDate] Between #" &
[Forms]![Main]![Child89].[Form]![txtBeginQAEvry5th] & "# And #" &
[Forms]![Main]![Child89].[Form]![txtEndQAStopEvry5th] & "#"

'Temporary debug code.
Debug.Print stLinkCriteria
Stop  'Look at the immediate window
       'and see if stLinkCriteria is properly formed
       'if so continue the code and check the result.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County


When I click the Command Button to open a form I receive the error:
Object Reuired.
This form is a subform connected to a main form.
Any suggestions?


Here is the code behind the Command Button:
Private Sub Command108_Click()
On Error GoTo Err_Command108_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frmQuery5"
'    stLinkCriteria = "[CallDate] Between [Forms]![Main]![Child89].
[Form]![txtBeginQAEvry5th] And [Forms]![Main]![Child89].[Form]!
[txtEndQAStopEvry5th]"
    stLinkCriteria = "[CallDate] Between #" & txtBeginQAEvry5th.Value
& "# and #" & txtEndQAStopEvry5th.Value & "#"
    DoCmd.OPENFORM stDocName, acNormal, , stLinkCriteria, acFormEdit
Exit_Command108_Click:
    Exit Sub
Err_Command108_Click:
    MsgBox Err.Description
    Resume Exit_Command108_Click
End Sub- Hide quoted text -

- Show quoted text -

Here's how my code looks after I changed it:

I get a Syntax error regarding the line: stLinkCriteria = "[CallDate]
Between "#" &

Any ideas?

Thanks,

Zufie


Private Sub Command108_Click()
On Error GoTo Err_Command108_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmQuery5"

stLinkCriteria = "[CallDate]Between "#" &
[Forms]![Main]![Child89].[Form]![txtBeginQAEvry5th] = "#" And "#"
& ""
[Forms]![Main]![Child89].[Form]![txtEndQAStopEvry5th] = "#"

Debug.Print stLinkCriteria
Stop

DoCmd.OPENFORM stDocName, acNormal, , stLinkCriteria, acFormEdit

Exit_Command108_Click:
Exit Sub

Err_Command108_Click:
MsgBox Err.Description
Resume Exit_Command108_Click

End Sub
 
J

John Spencer

This should all be on one line and you introduced extraneous quote marks
and equals signs.

stLinkCriteria = "[CallDate]Between "#" &
[Forms]![Main]![Child89].[Form]![txtBeginQAEvry5th] = "#" And "#"
& ""
[Forms]![Main]![Child89].[Form]![txtEndQAStopEvry5th] = "#"

I'll use line continuation characters.

stLinkCriteria = "[CallDate]Between #" & _
[Forms]![Main]![Child89].[Form]![txtBeginQAEvry5th] & _
"# And #" & _
[Forms]![Main]![Child89].[Form]![txtEndQAStopEvry5th] & "#"
'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

Try the following

stLinkCriteria = "[CallDate] Between #" &
[Forms]![Main]![Child89].[Form]![txtBeginQAEvry5th] & "# And #" &
[Forms]![Main]![Child89].[Form]![txtEndQAStopEvry5th] & "#"

'Temporary debug code.
Debug.Print stLinkCriteria
Stop 'Look at the immediate window
'and see if stLinkCriteria is properly formed
'if so continue the code and check the result.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County


When I click the Command Button to open a form I receive the error:
Object Reuired.
This form is a subform connected to a main form.
Any suggestions?
Thanks!
Zuf
Here is the code behind the Command Button:
Private Sub Command108_Click()
On Error GoTo Err_Command108_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmQuery5"
' stLinkCriteria = "[CallDate] Between [Forms]![Main]![Child89].
[Form]![txtBeginQAEvry5th] And [Forms]![Main]![Child89].[Form]!
[txtEndQAStopEvry5th]"
stLinkCriteria = "[CallDate] Between #" & txtBeginQAEvry5th.Value
& "# and #" & txtEndQAStopEvry5th.Value & "#"
DoCmd.OPENFORM stDocName, acNormal, , stLinkCriteria, acFormEdit
Exit_Command108_Click:
Exit Sub
Err_Command108_Click:
MsgBox Err.Description
Resume Exit_Command108_Click
End Sub- Hide quoted text -
- Show quoted text -

Here's how my code looks after I changed it:

I get a Syntax error regarding the line: stLinkCriteria = "[CallDate]
Between "#" &

Any ideas?

Thanks,

Zufie


Private Sub Command108_Click()
On Error GoTo Err_Command108_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmQuery5"

stLinkCriteria = "[CallDate]Between "#" &
[Forms]![Main]![Child89].[Form]![txtBeginQAEvry5th] = "#" And "#"
& ""
[Forms]![Main]![Child89].[Form]![txtEndQAStopEvry5th] = "#"

Debug.Print stLinkCriteria
Stop

DoCmd.OPENFORM stDocName, acNormal, , stLinkCriteria, acFormEdit

Exit_Command108_Click:
Exit Sub

Err_Command108_Click:
MsgBox Err.Description
Resume Exit_Command108_Click

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top