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

Form not closing. I know why, but need help to fix it.

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX
I have a form (frm_coils_add_new) with 18 data entry point on it. The last entry point on the form is the text box SC. Using the code below within Access 2000 to take the new data and store it to a SQL server database. When tabbing out of the text box #18 (On Exit property) SC the code below runs. The problem is that the cursor then returns to text box #1 and is still in edit mode. This code connot run while the form is in edit mode. I have tried the SC_AfterUpdate property as a trigger to execute this code and everything works fine but only if something is entered in the text box SC. If nothing is entered in text box SC and is tabbed out of the cursor returns to text box #1 and the code never executes. Is there a way to maybe turn off the edit (data entry) mode so the code can run and close the form? Thanks to all of you who have read this and replied.

Private Sub SC_Exit(Cancel As Integer)
Dim stDocName, stLinkCriteria As String: Entered = Now()
Dim CN As ADODB.Connection: Dim rs As ADODB.Recordset
SQLa = "Insert Into CoilSpec.dbo.coilspec (Coil,StartLeft,TT,TPL,BDim,RPM,[Cross]," & _
"Pick1,Pick2,Pick3,Pick4,Pick5,Pick6,Pick7,Pick8,Pick9,Pick10,SpecialComments,Entered) values" & _
"(" & cmbWCoilNo & "," & Toggle112 & "," & TT & "," & TPL & "," & BDim & "," & RPM & "," & [Cross] & _
"," & P1 & "," & P2 & "," & P3 & "," & P4 & "," & P5 & "," & P6 & "," & P7 & "," & P8 & "," & P9 & _
"," & P10 & ", '" & SC & "' , '" & Entered & "' );"
Set CN = New ADODB.Connection: CN.Open "driver={SQL Server};" & _
"server=172.16.6.172;database=coilspec;uid=dtuttle;password=mpmadmin"
Set rs = CN.Execute(SQLa, , adCmdText)
CN.Close: Set rs = Nothing: Set CN = Nothing
MsgBox "Coil entry successfully saved"
DoCmd.Close

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top