L
lmv
I need to be able to put the DMAX inbetween 2 other fields
My PurchaseOrderNumber in the tbl Orders is the following AAAA0123BC
At this point I have a PurchaseOrderNumber that is a txtfield that included
the above and stored it. I have just been changing the number at the end but
it is annoying to do this. It was suggested that I do the following so I made
a lngCountPO field.
"separate number field and NO PurchaseOrderNumber field at all. You can
then combine all three fields together for *display* and call it a PONumber.
It does not need to have a separate field in the table.
If the numeric portion is in its own field then it's fairly easy to DMax() +
1
to get the next number."
So I have 3 fields:
4 letters are the ProjectID (txt field) (tblOrders)
Numbers are lngCountPO (NumberField) (tblOrders)
2 Letters are the PurchaserID (txt field) (tblOrders)
Unfortunately it was never posted back HOW to Display the 3 together and I
am not knowledgeable enough to figure out the syntax myself.
I saw some code that had the ability to take the number portion from the txt
portion and increase it. But again I couldn't figure out how to adjust it
because it was using date fields etc. I tried the following but I could never
get the imax line to not be red
Private Sub Form_BeforeInsert(Cancel as Integer)
Dim iMax As Integer
Dim strID As String
strID = DMax("[PurchaseOrderNumber]", "[Orders]") ' find biggest existing ID
iMax = Val(Mid(strID, 4) ' extract numeric portion
Me!PONumber = Format("ProjectID) & Format(iMax + 1, "0000") & ("PurchaserID")
End Sub
(By the way I don't even know what the iMax line means!!)
If anyone has a suggestion I'd appreciate it.
Thanks!
My PurchaseOrderNumber in the tbl Orders is the following AAAA0123BC
At this point I have a PurchaseOrderNumber that is a txtfield that included
the above and stored it. I have just been changing the number at the end but
it is annoying to do this. It was suggested that I do the following so I made
a lngCountPO field.
"separate number field and NO PurchaseOrderNumber field at all. You can
then combine all three fields together for *display* and call it a PONumber.
It does not need to have a separate field in the table.
If the numeric portion is in its own field then it's fairly easy to DMax() +
1
to get the next number."
So I have 3 fields:
4 letters are the ProjectID (txt field) (tblOrders)
Numbers are lngCountPO (NumberField) (tblOrders)
2 Letters are the PurchaserID (txt field) (tblOrders)
Unfortunately it was never posted back HOW to Display the 3 together and I
am not knowledgeable enough to figure out the syntax myself.
I saw some code that had the ability to take the number portion from the txt
portion and increase it. But again I couldn't figure out how to adjust it
because it was using date fields etc. I tried the following but I could never
get the imax line to not be red
Private Sub Form_BeforeInsert(Cancel as Integer)
Dim iMax As Integer
Dim strID As String
strID = DMax("[PurchaseOrderNumber]", "[Orders]") ' find biggest existing ID
iMax = Val(Mid(strID, 4) ' extract numeric portion
Me!PONumber = Format("ProjectID) & Format(iMax + 1, "0000") & ("PurchaserID")
End Sub
(By the way I don't even know what the iMax line means!!)
If anyone has a suggestion I'd appreciate it.
Thanks!