473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

New at Access and need help with an expression

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.
Aug 2 '07 #1
7 1231
BradHodge
166 Expert 100+
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...

Expand|Select|Wrap|Line Numbers
  1. Private Sub chkBillShip_AfterUpdate()
  2. If Me.chkBillShip = True Then
  3. Forms![frmBillShip]![subShipTo].Form![ShipName] = Me.BillName
  4. Forms![frmBillShip]![subShipTo].Form![ShipAdd] = Me.BillAdd
  5. Forms![frmBillShip]![subShipTo].Form![ShipCity] = Me.BillCity
  6. Forms![frmBillShip]![subShipTo].Form![ShipState] = Me.BillState
  7. Else:
  8. DoCmd.SetWarnings False
  9. Forms![frmBillShip]![subShipTo].SetFocus
  10. RunCommand acCmdDeleteRecord
  11. DoCmd.SetWarnings True
  12. End If
  13. End Sub
Hope that gets you going.

Brad.
Aug 2 '07 #2
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.
Aug 2 '07 #3
mlcampeau
296 Expert 100+
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]
Aug 2 '07 #4
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.
Aug 2 '07 #5
mlcampeau
296 Expert 100+
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
Aug 2 '07 #6
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.
Aug 2 '07 #7
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 :)
Aug 2 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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
6
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...
2
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...
23
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...
9
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...
4
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...
3
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...
1
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...
1
MMcCarthy
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 ...
13
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.