Form Load runs twice

dbalargin

Member
Local time
Today, 06:40
Joined
Dec 31, 2002
Messages
39
I have a Form that opens on start up. The form imports from a text file and transfers info. I have a command button on the form when it is pressed... the form load procedure fires again and imports the info again. I do not want this to happen. Hwo can I prevent the form load from running when I clcik a button.

On Error Resume Next
FileCopy "\\Jcksn1a1\Common\295097\Settlement_Form\Settlement_i.mdb", "C:\Settlement_i.mdb"
DoCmd.SetWarnings (0)

Me.cmdSubmit.Visible = False
Me.cmdCancel.Visible = False
Me.Combo8.Visible = False
Me.lblName.Visible = False
Me.lblTitle.Visible = True

On Error Resume Next
DoCmd.TransferText acImportDelim, "SText", "tblRaw_Settlement_Info", "G:\295097\Settlement_Form\SText.txt", 0 'import from text file
DoCmd.RunSQL "SELECT * INTO tblSettlement_Info FROM tblRaw_Settlement_Info" ' dump n2 tmp table
DoCmd.DeleteObject acTable, "tblRaw_Settlement_Info"
DoCmd.DeleteObject acTable, "SText_ImportErrors"
 
Put a check in the button event code to check to see if the form is already loaded, or take it out of the start up routine.
 

Users who are viewing this thread

Back
Top Bottom