Expression Builder in Access 03 Forms

  • Thread starter Thread starter Jan
  • Start date Start date
J

Jan

Hi all,
I'm creating a database that I will eventually publish to the web. I want to
create a form where if the shipping address is the same as the mailing
address, you click the button and the data fills into that field, if not, you
can enter your data.

I've gotten as far as =IIf([shipsameasmail]=Yes,[mailingstreet], ?) and then
I'm stuck. If I enter shipsameasmail as a last parameter, I'll get a circular
reference. If I create a separate field for this data, I'll have two fields
that contain the shipping information and the form will have two separate
places to enter.

Can anyone help with this?
 
Jan

You could use a check box where a tick would indicate the shipping address
is the same as the mailing address.

For this exercise we will call the tick box same_address, your Mailing
address we will call mailing_address and shipping_address for the Shipping
address

If me!same_address =True then
me!shipping_address =me!mailing_address
else
me!shipping_address=Null
end if

The Else is used to set the shipping address to NULL when you untick the
same address check box

Allan
 
Here's an untested code stub:

Sub chkSameAsMail_AfterUpdate()
If Me.chkSameAsMail = True Then
Me.txtShipName = Me.txtName
Me.txtShipAddress = Me.txtMailAddress
Me.txtShipCity = Me.txtMailCity
Me.txtShipState = Me.txtMailState
Me.txtShipZip = Me.txtMailZip
Else
If MsgBox ("Please fill in shipping details", vbOKCancel) = vbOK
Then
Me.txtShipName = ""
Me.txtShipAddress = ""
Me.txtShipCity = ""
Me.txtShipState = ""
Me.txtShipZip = ""
End If
End Sub
 
Thank you.

This worked but I couldn't figure out the message box. It gave me multiple
errors with different variations I tried.

Private Sub shipsameasmail_AfterUpdate()
If Me.shipsameasmail = True Then
Me.physicalstreet = Me.mailingstreet
Me.physicalstreet2 = Me.mailingstreet2
Me.physicalcity = Me.mailingcity
Me.physicalstate = Me.mailingstate
Me.physicalzip = Me.mailingzip
Else
Me.physicalstreet = ""
Me.physicalstreet2 = ""
Me.physicalcity = ""
Me.physicalstate = ""
Me.physicalzip = ""
End If
End Sub
--
Thanks!
Jan


Arvin Meyer said:
Here's an untested code stub:

Sub chkSameAsMail_AfterUpdate()
If Me.chkSameAsMail = True Then
Me.txtShipName = Me.txtName
Me.txtShipAddress = Me.txtMailAddress
Me.txtShipCity = Me.txtMailCity
Me.txtShipState = Me.txtMailState
Me.txtShipZip = Me.txtMailZip
Else
If MsgBox ("Please fill in shipping details", vbOKCancel) = vbOK
Then
Me.txtShipName = ""
Me.txtShipAddress = ""
Me.txtShipCity = ""
Me.txtShipState = ""
Me.txtShipZip = ""
End If
End Sub

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Jan said:
Hi all,
I'm creating a database that I will eventually publish to the web. I want
to
create a form where if the shipping address is the same as the mailing
address, you click the button and the data fills into that field, if not,
you
can enter your data.

I've gotten as far as =IIf([shipsameasmail]=Yes,[mailingstreet], ?) and
then
I'm stuck. If I enter shipsameasmail as a last parameter, I'll get a
circular
reference. If I create a separate field for this data, I'll have two
fields
that contain the shipping information and the form will have two separate
places to enter.

Can anyone help with this?
 
We might be able help if you gave us the error numbers, any description, and
exactly where the errors are happening. Also the version and service pack of
Access, might help.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Jan said:
Thank you.

This worked but I couldn't figure out the message box. It gave me multiple
errors with different variations I tried.

Private Sub shipsameasmail_AfterUpdate()
If Me.shipsameasmail = True Then
Me.physicalstreet = Me.mailingstreet
Me.physicalstreet2 = Me.mailingstreet2
Me.physicalcity = Me.mailingcity
Me.physicalstate = Me.mailingstate
Me.physicalzip = Me.mailingzip
Else
Me.physicalstreet = ""
Me.physicalstreet2 = ""
Me.physicalcity = ""
Me.physicalstate = ""
Me.physicalzip = ""
End If
End Sub
--
Thanks!
Jan


Arvin Meyer said:
Here's an untested code stub:

Sub chkSameAsMail_AfterUpdate()
If Me.chkSameAsMail = True Then
Me.txtShipName = Me.txtName
Me.txtShipAddress = Me.txtMailAddress
Me.txtShipCity = Me.txtMailCity
Me.txtShipState = Me.txtMailState
Me.txtShipZip = Me.txtMailZip
Else
If MsgBox ("Please fill in shipping details", vbOKCancel) = vbOK
Then
Me.txtShipName = ""
Me.txtShipAddress = ""
Me.txtShipCity = ""
Me.txtShipState = ""
Me.txtShipZip = ""
End If
End Sub

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Jan said:
Hi all,
I'm creating a database that I will eventually publish to the web. I
want
to
create a form where if the shipping address is the same as the mailing
address, you click the button and the data fills into that field, if
not,
you
can enter your data.

I've gotten as far as =IIf([shipsameasmail]=Yes,[mailingstreet], ?) and
then
I'm stuck. If I enter shipsameasmail as a last parameter, I'll get a
circular
reference. If I create a separate field for this data, I'll have two
fields
that contain the shipping information and the form will have two
separate
places to enter.

Can anyone help with this?
 
Back
Top