Step by step ... this is how the program should work:
1. User presses buttons 1, 2 and 3 on main form and gets a "sum" for the payroll for a specific time frame.
2. When the user presses the last button on main form, the form closes, the sum of the data is posted to a SQL database and a second form is opened.
3. The second form is a option group with 3 options, 1, 2, or 3 and a submit button.
4. The user chooses an option and presses the submit button on the second form, which then posts the option group result AND the timestamp to the SQL table. (the same SQL table where the information from the main form is posted)
5. Form 2 closes.
here is my code thus far:
Expand|Select|Wrap|Line Numbers
- Option Compare Database
- Dim batchid As String
- Dim sConn As String
- sConn = "Provider='SQLOLEDB';Data Source='xxxxx';" & _
- "Initial Catalog='xxxxx';"
- Set sConn = New ADODB.Connection
- .Open
- On Error GoTo DateStampError 'Error reporting on DateStamp code
- sqlStmt = "APPEND timestamp FROM [Payroll]"
- Set rs = CurrentDb().OpenRecordset(sqlStmt)
- With rs
- If .RecordCount = 0 Then
- .AddNew 'For first time use before a record added
- .Fields("fldDate") = Date
- .Update
- Else
- .MoveFirst
- .Edit
- .Fields("fldDate") = Date
- .Update
- End If
- End With
- rs.Close
- Set rs = Nothing
- SelectCase Me.Frame7.Value
- Case 1
- batchid = "='1'"
- Case 2
- batchid = "='2'"
- Case 3
- batchid = "='3'"
- End Select
- DateStampError:
- MsgBox "DateStamp code failed. " & Error$
- Resume Command2_Click_Exit
- End Sub
Thank you
Doug