Object Required

  • Thread starter Thread starter EdwardA
  • Start date Start date
E

EdwardA

Trying to manually construct a query within my search form
to look up shipments in 2 different tables within a period
of calendar days. When the query runs, both forms pop up
white, and I get the "Object Required" error.

Heres my code.

Private Sub Command3_Enter()
On Error GoTo Err_Command3_Enter

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "STOCK_WHSE27"
ssDocName = "STOCK_OUT"
srDocName = "TECH_RMA_Log"

ssLinkCriteria = "[Date Recieved]=" & "'" & Me![Text1]
& "'"
DoCmd.OpenForm ssDocName, , , ssLinkCriteria,
(((STOCK_WHSE27.[Date Recieved]) >= [Text1] And
(STOCK_WHSE27.[Date Recieved]) <= [Text2]))

stLinkCriteria = "[Date Recieved]=" & "'" & Me![Text1]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria,
(((STOCK_WHSE27.[Date Recieved]) >= [Text1] And
(STOCK_WHSE27.[Date Recieved]) <= [Text2]))

DoCmd.RunCommand acCmdTileHorizontally

Exit_Command3_Enter:
Exit Sub

Err_Command3_Enter:
MsgBox Err.Description
Resume Exit_Command3_Enter

End Sub


Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "STOCK_WHSE27"
ssDocName = "STOCK_OUT"
srDocName = "TECH_RMA_Log"

ssLinkCriteria = "[Date Recieved]=" & "'" & Me![Text1]
& "'"
DoCmd.OpenForm ssDocName, , , ssLinkCriteria,
(((STOCK_WHSE27.[Date Recieved]) >= [Text1] And
(STOCK_WHSE27.[Date Recieved]) <= [Text2]))

stLinkCriteria = "[Date Recieved]=" & "'" & Me![Text1]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria,
(((STOCK_WHSE27.[Date Recieved]) >= [Text1] And
(STOCK_WHSE27.[Date Recieved]) <= [Text2]))

DoCmd.RunCommand acCmdTileHorizontally

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub
 
What is (((STOCK_WHSE27.[Date Recieved]) >= [Text1] And (STOCK_WHSE27.[Date
Recieved]) <= [Text2])) supposed to be? You've got it as the 4th parameter
of the OpenForm method, which is supposed to be the DataMode (one of
acFormAdd, acFormEdit, acFormPropertySettings or acFormReadOnly)

If [Date Recieved] is a date field, you need to delimit the date using #
(and it must be in mm/dd/yyyy format, regardless of what the regional
settings are on the machine)

You've also got a lot of undeclared variables in your routine, which makes
me suspect you don't have Option Explicit turned on.
 
(((STOCK_WHSE27.[Date Recieved]) >= [Text1] And >
(STOCK_WHSE27.[Date
Recieved]) <= [Text2])) supposed to be?

Its a first attempt at locating data between dates on
multiple tables. I was using access queries up until this
point, but found that I could only search one table at a
time with it. I need to search and generate results from
three different sources, and am attempting to eliminate
the redundancy of entering in the dates multiple times per
search attempt.

My date is limited on the text box using the mm/dd/yyyy
format. Is that all that is needed?
You've also got a lot of undeclared variables in your
routine, which makes
me suspect you don't have Option Explicit turned on.

I dont even know what that is. Im still very much a
novice.
 
Try:

ssLinkCritera = "(((STOCK_WHSE27.[Date Recieved]) >= #" & [Text1] & _
"# And (STOCK_WHSE27.[Date Recieved]) <= #" & [Text2] & "#"))
DoCmd.OpenForm ssDocName, , , ssLinkCriteria

(Hopefully that won't have word-wrap. That's supposed to be 3 lines of code.
The first line ends & _, the second line starts "# and ends "#")), and the
last line starts DoCmd.)

Note that this will only work if your dates are in mm/dd/yyyy format (or
some unambiguous format, such as dd mmm yyyy or yyyy-mm-dd).

Take a look at the following for more information about Option Explicit:
http://msdn.microsoft.com/library/en-us/vbenlr98/html/vastmOptionExplicit.asp

It's an extremely important issue.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


EdwardA said:
(((STOCK_WHSE27.[Date Recieved]) >= [Text1] And > (STOCK_WHSE27.[Date
Recieved]) <= [Text2])) supposed to be?

Its a first attempt at locating data between dates on
multiple tables. I was using access queries up until this
point, but found that I could only search one table at a
time with it. I need to search and generate results from
three different sources, and am attempting to eliminate
the redundancy of entering in the dates multiple times per
search attempt.

My date is limited on the text box using the mm/dd/yyyy
format. Is that all that is needed?
You've also got a lot of undeclared variables in your
routine, which makes
me suspect you don't have Option Explicit turned on.

I dont even know what that is. Im still very much a
novice.
 
Back
Top