Adding to VB Procedure

B

BillA

A while back I had help developing a Visual Basic procedure. I would like to
reuse this procedure and add to it and I've been unable to figure out how to
do it.

This is what I have:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim varMax As Variant
Dim DocID As String
DocID = VBA.Year(Date)
varMax = Nz(DMax("Val(Mid(emplID, 5))", _
"DPH_Staff_appended", _
"emplID Like """ & DocID & "*"""), 0) + 1
Me.[EmplID] = DocID & Format(varMax, "000")

End Sub

This produces a new employee ID number based upon the calendar year:
2008001, 2008002 etc...
I would like to add 4 additional numbers that would identify the unit the
employee data was entered from. For example the central office identifier
is: 0294, another unit is 8300 etc...
I'm looking for an employee number that would read:
20080294001, 20080294002 etc... or 20088300001, 20088300002 etc...
Another approach would be to remove the year and just use the last 7 digits
- advice on both approaches would be appreciated.

Thank you,
Bill
 
B

BillA

Hello Ruralguy:
My theory was to place the appropriate unit number in the procedure prior to
shipping it off to the disparate users. These users would use this simple
access db to enter local training related staff information. Occasionally
these units would send output (possibly a spreadsheet) containing specific
information to be consolidated in a master Access db. By having unit
specific EmplID’s, which is the primary key, I can be assured of
non-duplicative records. At the present time I’m considering the date
portion may be unnecessary.

Thank you for your interest.
Bill

ruralguy via AccessMonster.com said:
How are you planning to determine the "the unit the
employee data was entered from"?
A while back I had help developing a Visual Basic procedure. I would like to
reuse this procedure and add to it and I've been unable to figure out how to
do it.

This is what I have:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Dim varMax As Variant
Dim DocID As String
DocID = VBA.Year(Date)
varMax = Nz(DMax("Val(Mid(emplID, 5))", _
"DPH_Staff_appended", _
"emplID Like """ & DocID & "*"""), 0) + 1
Me.[EmplID] = DocID & Format(varMax, "000")

End Sub

This produces a new employee ID number based upon the calendar year:
2008001, 2008002 etc...
I would like to add 4 additional numbers that would identify the unit the
employee data was entered from. For example the central office identifier
is: 0294, another unit is 8300 etc...
I'm looking for an employee number that would read:
20080294001, 20080294002 etc... or 20088300001, 20088300002 etc...
Another approach would be to remove the year and just use the last 7 digits
- advice on both approaches would be appreciated.

Thank you,
Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top