bassman197
Registered User.
- Local time
- Today, 12:48
- Joined
- Sep 18, 2007
- Messages
- 35
Not exactly what I want to do, but very similar! In our contract writing program, ONE client may have MANY vendors. Usually, all the vendors are reporting to the same address - the one on the client's contract, so I usually want all of the vendor contracts to display the same location address as the one on the client's. But what if the florist needs to go to the church and all the other vendors need to go to the banquet hall? I need a way to have the client address be the default on the vendor contract, while allowing an alternate address to be entered if needed. I'm thinking of adding a yes/no field to the vendor contract called UseAlternateAddress, which would default to no. Then putting something like this on the ON CURRENT function for the vendor contract form:
on current:
If me.UseAlternateAddress.value = no then
me.VendorLocationName.controlsource = forms![ClientLocationName]me.VendorLocationAddress.controlsource = forms![ClientLocationAddress]
(etc for City, State, zip) ELSE
me.VendorLocationName.controlsource = me.[AltLocationName]
me.VendorLocationAddress.controlsource = me.[AltLocationAddress]
(etc for City, State, zip - the Alt fields reside in the same table as the other vendor fields, along with the UseAlternateAddress yes/no field).
End If
End Sub
This sounds like it should work, but seems like a sweeping change, giving Access a lot to calculate as someone is using the mouse wheel to scroll through the vendor contracts. Maybe I'm just being overly cautious - is using VBA to change a control source common practice? I just don't want to introduce anything that would make the progarm error-prone. Any advice appreciated!
(The only other way I can think of: I could also just have vendor address fields filled in with the same info as the client address by default, then the user could simply type over them if needed (no control source manipulation needed). But this means that the same address would be stored in two different places (or more, if 7 or 8 vendors!) - not a very elegant solution.)
on current:
If me.UseAlternateAddress.value = no then
me.VendorLocationName.controlsource = forms![ClientLocationName]me.VendorLocationAddress.controlsource = forms![ClientLocationAddress]
(etc for City, State, zip) ELSE
me.VendorLocationName.controlsource = me.[AltLocationName]
me.VendorLocationAddress.controlsource = me.[AltLocationAddress]
(etc for City, State, zip - the Alt fields reside in the same table as the other vendor fields, along with the UseAlternateAddress yes/no field).
End If
End Sub
This sounds like it should work, but seems like a sweeping change, giving Access a lot to calculate as someone is using the mouse wheel to scroll through the vendor contracts. Maybe I'm just being overly cautious - is using VBA to change a control source common practice? I just don't want to introduce anything that would make the progarm error-prone. Any advice appreciated!
(The only other way I can think of: I could also just have vendor address fields filled in with the same info as the client address by default, then the user could simply type over them if needed (no control source manipulation needed). But this means that the same address would be stored in two different places (or more, if 7 or 8 vendors!) - not a very elegant solution.)