Access 2002, need to call OpenForm twice to display record data

  • Thread starter Thread starter Raven
  • Start date Start date
R

Raven

Can someone explain why I had to call OpenForm twice to get the form
to include the filtered record data. When the OpenForm is only called
once the form opens properly but there is no record attached to it. If
I call the openForm the second time, the data is display. I have
include the code:

Dim stDocName As String
Dim stLinkCriteria As String
Dim strTest As String

stDocName = "frmCaseSummary"
CaseNumber.SetFocus
strTest = CaseNumber.Text
Me.Visible = False

stLinkCriteria = "[CaseNumber]=" & "'" & strTest & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.OpenForm stDocName, , , stLinkCriteria

Thanks
 
Hi Raven,

From your descriptions, I understand that when you try to open a form by
docomd.openform, you have to repeat the code to get the correct data
displayed. Have I understand you? If there is anything I misunderstood,
please feel free to let me know.

I make a test based on your codes in the post, however, I could not
reproduce the situation as you described. Just one OpenForm will open the
Form and return the data I assumed.

Based on my knowledge, there may exists some attribute error in codes or
frmCaseSummary. If you create a new Form, do you have to open it with
repeated DoCmd.OpenForm? or if you create a new mdb file, do you have to
open another form with repeated DoCmd.OpenForm? If you still encounter
those issues, would you please show me sample data or file so that I could
reproduce it on my machine, which, I belive, will get us closer to the
resolutions.

Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are here to be of assistance!

Sincerely yours,

Michael Cheng
Microsoft Online Support
***********************************************************
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks.
 
Thank-you Michael,
Re-examining the form's properties I found that 'Data Entry' was
inadvertently set to Yes which did not allow the filtered record's
data be displayed.
 
Hi Folks.

I have the same problem.

I open a 2nd form with the WHERE arg in the OpenForm method.
It had been finding the ProjectID I was looking for.

Then I added code to check to see if a project was in the table, and if not, create a recordset (rst), insert the new record, Update it, close the rst, CurrentDB, and the Connection.

Then it continues with the same code as above to just WHERE the projectid matches the one I just inserted, and the form comes up with a projectid of 0 (zero).

I exited and checked the 2nd form's main table, and the new record is there.
If I close the 2nd form, and perfomr the search again, it does find it, similar to Raven.

Users do have to do entry on the 2nd form's table tho, so I don't know if I should say DataEntry No? I will check out DataEntry, per Raven.
 
Back
Top