I have a form that is a combination of 2 tables: Bill To and Ship To. In my Bill To table, I have a column "Bill To =Ship To" and that appears on the form. What I am trying to do is build an expression that would fill in the shipping address, shipping city, etc automatically when Y is the input in "Bill to = Ship To.
I am not sure if I would use and if expression or what.
Any help is greatly appreciated. Thanks.
7 1231
I'm not sure exactly how your form is set-up, but here is an example of how it could be done. If you have the Parent form ("frmBillShip") recordsource as "Bill To" and there is a subform ("subShipTo") with the recordsource of "Ship To", and there is a checkbox called "chkBillShip", then your code could look something like this... - Private Sub chkBillShip_AfterUpdate()
-
If Me.chkBillShip = True Then
-
Forms![frmBillShip]![subShipTo].Form![ShipName] = Me.BillName
-
Forms![frmBillShip]![subShipTo].Form![ShipAdd] = Me.BillAdd
-
Forms![frmBillShip]![subShipTo].Form![ShipCity] = Me.BillCity
-
Forms![frmBillShip]![subShipTo].Form![ShipState] = Me.BillState
-
Else:
-
DoCmd.SetWarnings False
-
Forms![frmBillShip]![subShipTo].SetFocus
-
RunCommand acCmdDeleteRecord
-
DoCmd.SetWarnings True
-
End If
-
End Sub
Hope that gets you going.
Brad.
OK...I really don't understand that much of what you said, sorry. Let me try to explain what I have and am trying to do a little bit better.
I have a table called "Customers and it includes billing address, etc and a column "billto=shipto" where i can enter a "y" if it does. I have another table "ShipTo and it includes shipping address, etc. The tables are linked by a customer ID. I created a form and a query by combing the 2 tables. What I am trying to do is have the shipping address,etc filled in automatically when the "billto=shipto" is marked with a "y." I don't know anything about code, but I was thinking I could build a relationship and put it as a default value in the design view of either the form or the query. Something along the lines of If [customers!billto=shipto] =y then [ShipTo!shippingaddress] = [Customers!billingaddress]
I am a little more comfortable with building this kind of expression but I know I am not bracketing where I need to. Will anything like this work for me and where do I put it.
Sorry for my ignorance.
OK...I really don't understand that much of what you said, sorry. Let me try to explain what I have and am trying to do a little bit better.
I have a table called "Customers and it includes billing address, etc and a column "billto=shipto" where i can enter a "y" if it does. I have another table "ShipTo and it includes shipping address, etc. The tables are linked by a customer ID. I created a form and a query by combing the 2 tables. What I am trying to do is have the shipping address,etc filled in automatically when the "billto=shipto" is marked with a "y." I don't know anything about code, but I was thinking I could build a relationship and put it as a default value in the design view of either the form or the query. Something along the lines of If [customers!billto=shipto] =y then [ShipTo!shippingaddress] = [Customers!billingaddress]
I am a little more comfortable with building this kind of expression but I know I am not bracketing where I need to. Will anything like this work for me and where do I put it.
Sorry for my ignorance.
If you have a field named billto=shipto, you may want to change that. The equal sign might or probably will give you troubles. Try BillToEqualsShipTo or something instead. Then in your query you could have
ShippingAddress: IIF([Customers.BillToEqualsShipTo]="Y", [Customers.BillingAddress], [ShipTo.ShippingAddress])
Meaning, if [Customers.BillToEqualsShipTo]="Y" then [Customers.BillingAddress] else [ShipTo.ShippingAddress]
If you have a field named billto=shipto, you may want to change that. The equal sign might or probably will give you troubles. Try BillToEqualsShipTo or something instead. Then in your query you could have
ShippingAddress: IIF([Customers.BillToEqualsShipTo]="Y", [Customers.BillingAddress], [ShipTo.ShippingAddress])
Meaning, if [Customers.BillToEqualsShipTo]="Y" then [Customers.BillingAddress] else [ShipTo.ShippingAddress]
Thanks. I will change the field and get rid of the "=" . One more question: What is that character before the IF in your formula? It looks like a capital I, but I am not sure.
Thanks. I will change the field and get rid of the "=" . One more question: What is that character before the IF in your formula? It looks like a capital I, but I am not sure.
it is an i so it is iif. Not sure why, but that's how access wants if written
it is an i so it is iif. Not sure why, but that's how access wants if written
Thanks so much for all of your help.
NeoPa 32,556
Expert Mod 16PB
it is an i so it is iif. Not sure why, but that's how access wants if written
Why is IIf() so called I wonder? Good question.
Nice going anyway MLCampeau. Your status change is pending by the way - we haven't forgotten about you :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mike MacSween |
last post by:
This looks like a bug to me.
I have an expression on a report:
=Format(Sum((**)*(/)),"0.00")
Score is byte
PercentOfGrade is double
PropDegree is single
ModuleCats is byte
|
by: John Baker |
last post by:
Hi:
As those who have looked at this newsgroup recently will realize, I am a neophyte with
Access, although I have experienced with Approach (the Lotus product). There are things I
could easily...
|
by: Armando |
last post by:
This is driving me nuts -
I 'm trying to open a table programmatically, to add or modify records, and
I can't put all the pieces together to make it work in Access 2000. I have
all sorts of apps...
|
by: Reggie |
last post by:
Hi and TIA. I developed several A2K dbs which are now being run on my
clients computer which have been upgraded to Access 03. I'm not sure
exactly what they mean but of you know or could point me...
|
by: Alan Mailer |
last post by:
Ok, my Access 2002 language writing skills are VERY rusty,. I would
know how to do what I need using SQL Server's "Coalesce' function, but
I don't have that available to me in the Access 2002...
|
by: Anja |
last post by:
Hi everyone,
I am trying to use the expression builder to create input to a control
in an Access report.
I have a table called Records and I want to select the minimum date for
a record where...
|
by: Sheldon |
last post by:
I have the following query expression -
Like Format((!!)) & "/*/" & (!
!)
which would translate to e.g. 04/*/2007 if someone is running a report
for last month. The above expression is part of a...
|
by: natalieo |
last post by:
Hi everyone ,
Hope all is well with you guys and girls :)
I saw someone had a similar posting in this forum and need some help also with a Access Query Expression.
I need an expression to...
|
by: MMcCarthy |
last post by:
Access has a number of built-in functions which can be generally used in queries or VBA code. Some of the more common ones are:
Note: anything in square brackets is optional
Date Functions
...
|
by: magickarle |
last post by:
Hi, I got a pass-through query (that takes about 15 mins to process)
I would like to integrate variables to it.
IE: something simple:
Select EmplID from empl_Lst
where empl_lst.timestamp between...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |