I am recieving a duplicate declaration in current scope error message
Posted on 2004-11-04
I am developingr an employee training database for the company and with this code I want the user to check in a checkbox if the user has taken a class or not. If the user has not taken the class then the checkbox should be empty and the user will then select a class and the class will go into my table. If the user does select the checkbox then they will have enter the class and a date the class was taken. One of first problems is that if the user does not check the checkbox and does not enter in a date then an error message comes up. If the user does select the checkbox and enter in a date then the code works fine. Does anyone have any suggestions as to how I can enter the information in the table without the user having to enter in a date and disable the date field if the checkbox is not selected ?
Private Sub cmdTrain_Click()
Dim ClassDate As Date
Dim empID As Integer
Dim occid As Integer
Dim req As Variant
Dim classtaken As Integer
Dim strSQL As String
Dim str1SQL As String
ClassDate = Me.Date
occid = Me.OccupationID
req = cboClass.Column(0)
classtaken = -1
empID = cboemp.Column(0)
If Me.classcheck.Value = True Then
Me.Date.Enabled = False
If Not IsDate(Me.Date.Value) Then
MsgBox "Please enter a valid date"
If Not IsNull(cboClass.Column(0) And Me.Date) Then
strSQL = "INSERT INTO Employee_Train (FileID, OccupationID, ClassID, ClassTaken, DateTaken) VALUES (" & empID & ", " & occid & ", " & req & ", " & classtaken & ", #" & ClassDate & "#)"
ElseIf IsNull(Me.Date) Then
str1SQL = "INSERT INTO Employee_Train(FileID, OccupationID, ClassID, ClassTaken, DateTaken) VALUES (" & empID & ", " & occid & ", " & req & ", " & classtaken & ")"