Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.OpenForm problems

Status
Not open for further replies.

cloakski

Programmer
Dec 13, 2002
8
US
I am using the following code (on a list double click) to open a form and the first time the form launches it comes up blank. While the form is open, if I double click the item in the list again (which is on a form in the background) all the data is loaded ok. All clicks following the 2nd are also ok. Its just that first one that launches the form that is messed up.

I put a break point in there and the data in the query is correct. What am I doing wrong?
 
I forgot this....

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmTestCase"

stLinkCriteria = "[TestCaseID] = " & "'" & Me![lstMR] & "'"
DoCmd.OpenForm stDocName, acNormal, , stLinkCriteria
 
The first thing that comes to mind is that something in the form's Open event procedure is preventing it from displaying data. Form_Open only runs when the form is initially launched, not when you do subsequent OpenForm method calls. What is in the Form_Open procedure of frmTestCase? Rick Sprague
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
There is no open event. Below is the code for the form. Perhaps I can create an open procedure to grab run the line of code from my main form. Basically grabbing the ID from the list, since it is still running in the background.


Option Compare Database
Private Sub Form_Close()
Forms.frmMainTrack.cmdFilter_Click
End Sub
Private Sub Close_Click()
On Error GoTo Err_Close_Click


DoCmd.Close

Exit_Close_Click:
Exit Sub

Err_Close_Click:
MsgBox Err.Description
Resume Exit_Close_Click

End Sub
 
I thought of something else. If the last time frmTestCase was saved, it had a filter active, then the stored form starts out with filtering turned on. That, in combination with your strCriteria on OpenForm, might be eliminating all the records.

It doesn't explain why it works the second and subsequent times, but I can't think what else would be happening, so I'm grasping at straws.

Does frmTestCase's recordset contain TestCaseID? Does your list box bound column number contain TestCaseID? Is TestCaseID a text field? Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Well I ended up just calling DoCmd.OpenForm right before I call it with the query passed to it. Seems to work ok and there is no visible difffernce to the user. So while its a dirty solution, I'm semi-happy with it. I may come back to it later.

But to answer your questions.


Does frmTestCase's recordset contain TestCaseID?
Yes
Does your list box bound column number contain TestCaseID?
Yes
Is TestCaseID a text field?
It is in the form I am trying to open.
 
Well, I'm glad you've got it working, at least. Sorry I couldn't be of more help. Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Its ok, my lack of VBA knowledge means I probably screwed something up while playing around with settings.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top