Advertisement
Advertisement
| 05.13.2008 at 10:45PM PDT, ID: 23400374 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: |
Private Sub CommandButton1_Click()
' record button
If CommandButton1 = OnAction Then
' variables
'Dim conn As ADODB.Connection
Dim sSQL As String
Dim lRecordsAffected As Long
Const EStoreman = "SL" ' email address
Const EEngineers = "Eng1" ' email address
Const ESupervisor = "GG" ' email address
' Open DB Connection
' Initialize variables.
Dim cn As New ADODB.Connection
Dim provStr As String
' Specify the OLE DB provider.
cn.Provider = "sqloledb"
' Specify connection string on Open method.
provStr = "Server=******;Database=Fault1;Trusted_Connection=yes"
cn.Open provStr
End If
If cn.State = adStateOpen Then
sSQL = "INSERT INTO Faultlog100 (Date,Machine,Equipment,Engineer,Engineer2,JobType,Fault,Repair,FurtherWork,Priority,Timeneeded,Partsused,Partsrequired,StartedHr,StartedMin,FinishedHr,FinishedMin) VALUES ('" & Format(Now, "YYYY-MM-DD") & "','" & TextBox9.Value & "','" & TextBox2.Value & "','" & ComboBox3.Value & "','" & ComboBox8.Value & "','" & ComboBox1.Value & "','" & TextBox1.Value & "','" & TextBox5.Value & "','" & ComboBox2.Value & "','" & ComboBox4.Value & "','" & ComboBox5.Value & "','" & TextBox6.Value & "','" & TextBox7.Value & "','" & ComboBox6.Value & "','" & ComboBox9.Value & "','" & ComboBox7.Value & "','" & ComboBox10.Value & "');"
lRecordsAffected = ActionQuery(cn, sSQL)
MsgBox "Record Added to Dbase", vbOKOnly
cn.Close
End If
Set cn = Nothing
End Sub
Public Function ActionQuery(cn As ADODB.Connection, _
sSQL As String) As Long
Dim lRecordsAffected As Long
Dim cmd As ADODB.Command
lRecordsAffected = 0
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = cn
.CommandText = sSQL
.CommandType = adCmdText
.Execute lRecordsAffected
End With
Set cmd = Nothing
exitpoint:
ActionQuery = lRecordsAffected
Exit Function
End Function
|