Auto populate Fields (1 Viewer)

stu_c

Registered User.
Local time
Today, 08:59
Joined
Sep 20, 2007
Messages
489
Hi all
I have 3 fields in a form

MainProductRef:
SubProductRef:
SlaveProductRef:

If I type in MainProductRef field is it possible to populate the other two fields with the same ref but with an extra number on the end, for example

MainProductRef: - ABC/1
SubProductRef: - ABC/1/A1 (auto Generate)
SlaveProductRef: ABC/1/B2 (auto Generate)

sometimes there is times I need to change the Sub product ref if necessary and automatically change Slave to this also for example

MainProductRef: - ABC/1
SubProductRef: - ABC/1/A2
SlaveProductRef: ABC/1/A2B (auto Generate)

is this possible?
 

June7

AWF VIP
Local time
Today, 00:59
Joined
Mar 9, 2014
Messages
5,423
Probably possible. Programmatically generating unique identifiers is a common topic. Will require VBA code.

Appears you want to append letters as well as numbers. Why the letter B in the example?
 

stu_c

Registered User.
Local time
Today, 08:59
Joined
Sep 20, 2007
Messages
489
just have to on how things are processed
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:59
Joined
May 7, 2009
Messages
19,169
you must build the subProductRef and SlaveProductRef on your own rule.
obviously (I think) subproductref build its code by combining subproduct a slash and the first letter of the mainproductref, plus an index:
Code:
[subProductRef] = [mainProductRef] & "/" & left(mainProductRef,1) & _
    Nz(dcount("1", "[subProductRef]", "yourTable", _
    "Left([subProductRef], " & Len[mainProductRef]+1 & ")='" & _
    [mainProductRef] & Left([mainProductRef, 1) & "'"), 0) + 1
slaveProductRef is similar, only using the second letter of mainProductRef.

you can build the string on the AfterUpdate/beforeUpdate event of mainProductRef textbox.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:59
Joined
Oct 29, 2018
Messages
21,357
Hi stu. Pardon me for jumping in, but I was just going to say be careful what you ask for. Computers and code are very literal. If you can specify the exact rules or logic for what you want to happen, then it's possible. But if you're talking about "sometimes" you want things to happen a certain way depending on the user's whim, then this could get a little tricky to do.
 

Users who are viewing this thread

Top Bottom