Capturing from variable sources

G

Guest

On my weights form, users may enter the shipment weight into one of a choice
of 3 different fields. We cannot get away from that, it is inevitable due to
the type of business. They would only ever use one of them on any given
shipment, the other two fields would be left on default 0.

I then need to grab this weight from whichever field they have populated,
and store it in another field and use that as a mergefield and for other
purposes.

Lets say I have in my table and on my form:
Weight 1
Weight 2
Weight 3
Weight to use

How do I code the "Weight to use" field to look at each of the 3 possible
sources, and whichever one is populated, use that one and ignore the others?

I have fiddled around with some If not else and null types of code, trying
to work it out, but I have run out of time. So, your help, please!
Many thanks
CW
 
G

Guest

Hi CW,

Because at some point a user will try to enter numbers into more than one
field, you are in for lots of coding to go down this route, to cover all
eventualities, a better choice would be to use an option group, with the 3
weight measures in it, and then use that, combined with just one textbox for
a value. that way, you are sure that they can only have one value with 1 type
of measurement at any given time, no need for lots of coding!

PS you can use the result of the option group selection to change the
textbox label to help make things even clearer.

TonyT..
 
G

Guest

Tony -
thanks, yes that does sound like the best solution and I had already
wonderered about it, but I have not done an Option Group before and I wasn't
quite sure how to set it up so that whichever route was taken by the user,
that particular value would be selectable/selected as the data to be used for
merging etc.
In fact, I am still not sure!!
Could you kindly explain exactly how I should go about this?
Many thanks
CW
 
G

Guest

Hi again CW,

You can have your option group bound to the field 'weight to use', but it
can only store numerical incremental values, ie. 1,2,3, so probably not of
use to you if the tables are already in use. So I shall ignore that option
from here on in.

First, create a Frame on your form (from Toolbox), then drag and drop your 3
check or option buttons into it, rename the labels accordingly, they will
inherit the values of 1,2 & 3 in the order you 'dropped' them, then you can
select the Frame itself, and use the afterUpdate event of the Frame to find
out which option was selected, eg.
If Me.Frame1 = 2 (second option let's say Kg) Then
Me.txtHiddenControlBoundToWeightToUse = "Kg"
Me.lblWeight.Caption = "Enter Weight In Kg:"
End If

PS the default value for the Frame determines which option/check box is
selected to start with.

Hope that helps a bit,

TonyT..
 

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

Top