I've been trying to put the final touches on some code that a user has helped me with but for the life of me I cannot find out why I'm getting a data type mismatch error 13.
I have a user form that workers fill out. They fill out this record every two hours. At times, they need to create duplicate records. The only difference being that the time of the record would be different from the time of the last record. Basically a user has six times during their shift that they have to complete records, 630am, 830am, 1030am, 1230pm, 230pm, end-days.
There are times when a worker would create a record at 630am and at the same time have to duplicate the record but only change the time to 830, 1030, and so on.
Instead of the worker having to fill out the entire form three times, with the same info except for the record time, I had in mind to have additional checkboxes on the form to represent the additional time records needed. The user would fill out the form once, select the checkboxes for the additional records, press a command button, and the records would be created, each a duplicate of the other but with the time field being different.
Below is the code that a user graciously helped me with. I am getting a data type mismatch error 13 on the "Call addentry(varTime)" entry. I've tried changing the data types to match each other as well as changing them all together.
Somewhere I'm missing something really basic (probably to most) and I'm hoping to get that final help to move past this development piece.
Here is the code I'm working with: I had commented out some of the code for troubleshooting purposes. I've also attached a stripped down version of my DB, created in Access 2010. I've tried to save the db in a lower version but I'm getting an error that states I have elements in this db that cannot be saved in a lower version.
I have a user form that workers fill out. They fill out this record every two hours. At times, they need to create duplicate records. The only difference being that the time of the record would be different from the time of the last record. Basically a user has six times during their shift that they have to complete records, 630am, 830am, 1030am, 1230pm, 230pm, end-days.
There are times when a worker would create a record at 630am and at the same time have to duplicate the record but only change the time to 830, 1030, and so on.
Instead of the worker having to fill out the entire form three times, with the same info except for the record time, I had in mind to have additional checkboxes on the form to represent the additional time records needed. The user would fill out the form once, select the checkboxes for the additional records, press a command button, and the records would be created, each a duplicate of the other but with the time field being different.
Below is the code that a user graciously helped me with. I am getting a data type mismatch error 13 on the "Call addentry(varTime)" entry. I've tried changing the data types to match each other as well as changing them all together.
Somewhere I'm missing something really basic (probably to most) and I'm hoping to get that final help to move past this development piece.
Here is the code I'm working with: I had commented out some of the code for troubleshooting purposes. I've also attached a stripped down version of my DB, created in Access 2010. I've tried to save the db in a lower version but I'm getting an error that states I have elements in this db that cannot be saved in a lower version.
Code:
Option Compare Database
Option Explicit
Sub AddRecords_Click()
Dim varTime As String
If cb430AM.Value = True Then
varTime = "End-Nights"
Call addentry(varTime)
End If
If cb630AM.Value = True Then
varTime = "6:30 AM"
Call addentry(varTime)
End If
'If cb830AM.Value = True Then
' varTime = "8:30 AM"
' Call addentry(varTime)
'End If
'If cb1030AM.Value = True Then
' varTime = "10:30 AM"
' Call addentry(varTime)
' End If
'If cb1230PM.Value = True Then
' varTime = "12:30 PM"
' Call addentry(varTime)
'End If
'If cb230PM.Value = True Then
' varTime = "2:30 PM"
' Call addentry(varTime)
'End If
'If cb430PM.Value = True Then
' varTime = "4:30 PM"
' Call addentry(varTime)
'End If
'If cb630PM.Value = True Then
' varTime = "6:30 PM"
' Call addentry(varTime)
'End If
'If cb830PM.Value = True Then
' varTime = "8:30 PM"
' Call addentry(varTime)
'End If
'If cb1030PM.Value = True Then
' varTime = "10:30 PM"
' Call addentry(varTime)
'End If
'If cb1230AM.Value = True Then
' varTime = "12:30 AM"
' Call addentry(varTime)
'End If
'If cb230AM.Value = True Then
' varTime = "2:30 AM"
' Call addentry(varTime)
'End If
End Sub
Private Function addentry()
Dim db As Database
Dim rs As Recordset
Dim varTime As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("tblProductionNumbers", dbOpenDynaset)
rs.AddNew
rs("ManHoursID") = Me.ManHoursID.Value
rs("ProductionDate") = Me.ProductionDate.Value
rs("TimeID") = varTime
rs("LineID") = LineID.Value
rs("ProductID") = Me.ProductID.Value
rs("OperatorID") = Me.OperatorID.Value
rs("TailOffID") = Me.TailOffID.Value
rs("LF Run") = Me.[LF Run].Value
rs("LF Produced") = Me.[LF Produced].Value
rs("Comments") = Me.Comments.Value
rs.Update
rs.Close
db.Close
cb430AM.Value = False
cb630AM.Value = False
cb830AM.Value = False
cb1030AM.Value = False
cb1230PM.Value = False
cb230PM.Value = False
cb430PM.Value = False
cb630PM.Value = False
cb830PM.Value = False
cb1030PM.Value = False
cb1230AM.Value = False
cb230AM.Value = False
End Function