Can anyone here help me with a problem I have in Access.
I'm trying to create a form which would have 3 checkboxes, for Air, Electrical and Mechanical and next to them, an reference number for each.
This reference number needs to be sequential depending on the date
i.e
M01/05/08 would be first mechanical job in may 08
E10/05/08 would be 10th electrical job in may 08
and then the first number would reset to 01 at the beginning of each month. I've been given some code, but I'm a bit of a n00b in access so unsure what to do.
So far, I've created 3 checkboxes with 3 text boxes next to that which references back to the 3 columns in the table, labelled air, electrical and mechanical. I've been told to enter this code
but not sure where
and then
and also
which I'm assuming replaces the previous section.
It was mentioned that I have to create an unbound box for the first function which I've done but not sure where to enter it and guessing that I have to put something on the checkboxes in the 'after update' field.
Can someone help me please.
Thanks
I'm trying to create a form which would have 3 checkboxes, for Air, Electrical and Mechanical and next to them, an reference number for each.
This reference number needs to be sequential depending on the date
i.e
M01/05/08 would be first mechanical job in may 08
E10/05/08 would be 10th electrical job in may 08
and then the first number would reset to 01 at the beginning of each month. I've been given some code, but I'm a bit of a n00b in access so unsure what to do.
So far, I've created 3 checkboxes with 3 text boxes next to that which references back to the 3 columns in the table, labelled air, electrical and mechanical. I've been told to enter this code
Code:
Public Function GenerateProductID(ProdType As String) As String
Dim Prefix As String
Dim StrNextID As String
Dim Rs As DAO.RecordSet
Prefix = Left(ProdType,1) ' (E)lectrical, (M)echanical or (A)ir
'Select all product codes that begin with the prefix and end with the current month and year
Set Rs = CurrentDb.OpenRecordset("Select * From TblProducts Where Left(fldProductCode,1)='" & Prefix & "' And Right(fldProductCode,5) = '" & Format(Date(),"mm/yy") & "';")
'Is there any previous orders for this period?
If Rs.EOF And Rs.BOF Then
StrNextID = "01"
Else
StrNextID = Format(Rs.RecordCount +1 ,"00")
Rs.Close
End If
Set Rs = Nothing
GenerateProductID = StrNextID
Exit Function
but not sure where
and then
Code:
Me.ControlName = GenerateProductID(Me.ProductType)
and also
Code:
If Me.CheckBoxA = True Then
Me.ControlName = GenerateProductID("Air")
'Add the remaining code here
End If
If Me.CheckBoxM = True Then
Me.ControlName = GenerateProductID("Mechanical")
'Add the remaining code here
End If
If Me.CheckBoxE = True Then
Me.ControlName = GenerateProductID("Electrical")
'Add the remaining code here
End If
which I'm assuming replaces the previous section.
It was mentioned that I have to create an unbound box for the first function which I've done but not sure where to enter it and guessing that I have to put something on the checkboxes in the 'after update' field.
Can someone help me please.
Thanks