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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple DoCmd not working when form opening 2

Status
Not open for further replies.

NeilT123

Technical User
Jan 6, 2005
302
GB
Hi I am using some temporary tables to help with the speed of one of my more complicated forms and have run into a problem.

When the form opens I run the following code.

Code:
Private Sub Form_Open(Cancel As Integer)
DoCmd.SetWarnings False 'switch off warning messages re adding & deleting records
DoCmd.RunSQL ("INSERT INTO tblTEMPIfFertAppln SELECT * FROM qryfrmIfFertApplnP1 ORDER BY [FieldName] DESC")
DoCmd.RunSQL ("INSERT INTO tblTEMPfrmIFFertOM SELECT * FROM qryfrmIFFertOMP4")
DoCmd.RunSQL ("INSERT INTO tblTEMPFieldList SELECT * FROM qryfrmFertManureFieldList")
DoCmd.SetWarnings True 'reset warnings
Me.Requery
DoCmd.Maximize
End Sub

On the form I have an unbound list box with its rowsource

Code:
SELECT tblTEMPFieldList.FieldName, tblTEMPFieldList.FieldName2 FROM tblTEMPFieldList ORDER BY tblTEMPFieldList.FieldName;

If I open the temporary table whilst the form is open then it has the data in it but when the form opens the list box is blank. Any suggestions as to what might be wrong?
 
You may try to reset the RowSource property of the list box in the Load event procedure of the form.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How, when and where do you set the rowsource for your list box?

You may try:

Code:
Private Sub Form_Open(Cancel As Integer)
DoCmd.SetWarnings False 'switch off warning messages re adding & deleting records
DoCmd.RunSQL ("INSERT INTO tblTEMPIfFertAppln SELECT * FROM qryfrmIfFertApplnP1 ORDER BY [FieldName] DESC")
DoCmd.RunSQL ("INSERT INTO tblTEMPfrmIFFertOM SELECT * FROM qryfrmIFFertOMP4")
DoCmd.RunSQL ("INSERT INTO tblTEMPFieldList SELECT * FROM qryfrmFertManureFieldList")[red]
lstBox.rowsource = "SELECT FieldName, FieldName2 FROM tblTEMPFieldList ORDER BY FieldName; "[/red]
DoCmd.SetWarnings True 'reset warnings
Me.Requery
DoCmd.Maximize
End Sub

Just a guess...

Have fun.

---- Andy
 
Thank you for the prompt responses. Issue resolved, on to the next.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top