[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

temporarily remove fields from form

I use a mail merg utility to create word documents. This utility will place a bookmark froma field on the form onto the word document that it creates.

The form contains:
exam address
exam city
exam state

shipping address
shippin city
shipping state

an option box that allows the user to select exam or shipping address to be different.  So I want the shipping address ect... to be the same as exam address unless the user selects the option box to specify a different shipping address. How would I do this?
0
seamus9909
Asked:
seamus9909
  • 4
  • 3
  • 2
  • +2
1 Solution
 
rajshekherCommented:
Hi,

For this, you can place a check box in above of Shipping Address.

If user select this checkbox, then exam address and shipping address are same, and using javascript, you can push up the exam details into shipping address details for automatically fillup. If is is unchecked then user should fill up the shipping address.

Hope this will resolve your issue.
0
 
ienaxxxCommented:
using the simple javascript
function diffShipAddr(){
  document.getElementById("id_of_first_element").value="";
  document.getElementById("id_of_first_element").disabled=false;
 
  document.getElementById("id_of_second_element").value="";
  document.getElementById("id_of_second_element").disabled=false;
  
  ......
 
}

function sameShipAddr(){
  document.getElementById("id_of_first_element").value=document.getElementById("id_of_the_element_to_copy_from").value;
  document.getElementById("id_of_first_element").disabled=true;
 
  document.getElementById("id_of_second_element").value=document.getElementById("id_of_the_element_to_copy_from").value;
  document.getElementById("id_of_second_element").disabled=false;
  
  .....
 
}

Open in new window



then adding onload="sameShipAddr()" to your BODY TAG
and onClick event on the checkbox, that fires the diffShipAddr function.

HTH
0
 
als315Commented:
Is it MS Access or something else? In Access you can fill shipping address with the same values as exam address if this checkbox is not marked.
Afterupdate event for exam fields (exam address etc.):
If Not Me.MyCheckBox then  Me.[shipping address] = Me.[exam address]
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
in addition to setting the fields the same, you might also want to hide/show the additional fields on the form depending on the state of the check box:

 Me.MyShippingAddressControl.Visible = Not Me.MyCheckBox

 So if the checkbox is true (Billing and Shipping are the same), then the shipping control should not be shown.  If it's false, then it should be and it's default value is the billing address.

 Or some variation there of.

Jim.
0
 
seamus9909Author Commented:
Yes this is Access.  Will Javascript run in Access?

Im confused.
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<Will Javascript run in Access?>>

 No.  Think it's just a matter of ienaxxx believing they were in another area.  I've dropped into SQL Server and mySQL thinking I was answering an Access question.

 When you go by keywords for spotting questions, sometimes you end up in a topic area that is different then what you think and it's easy to miss.

Jim.
0
 
seamus9909Author Commented:
oh Ok that helps Jim.

Ok
0
 
seamus9909Author Commented:
sorry Im stillnot getting it.  If the user Selects the checkbox  [chkShipping] then I want the shipping address to be entered, if they dont select it the chk box then I want the ExamAddress , city state ect to fill the Shipping Address fields.
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<orry Im stillnot getting it.  If the user Selects the checkbox  [chkShipping] then I want the shipping address to be entered, if they dont select it the chk box then I want the ExamAddress , city state ect to fill the Shipping Address fields. >>

 Well like anything, there are a number of ways to approach this.   Personally, I would show both sets of addresses, have the check box "Same as billing address" next to the shipping address and when checked, the shipping fields are set to the billing, and the shipping controls are disabled.

 The BeforeUpdate event of the form would need to ensure that all fields are filled in.

 So here's the steps:

1. Initial form setup is that all the fields are there and are enabled.

2. Tab order is Bill To controls first, then check box, then ship to's, then "OK" or whatever after that.

3. As said above, for the AfterUpdate Event of the check box, you'll need to do:

   If Me.cbxCopyBillTo = True then
       Me.txtShipToName = Me.BillToName
       Me.txtShipToAddress1 = Me.txtBillToAddress1
       Me.txtShipToAddress2 = Me.txtBillToAddress2
       Me.txtShipToCity = Me.txtBillToCity
       Me.txtShipToState = Me.txtBillToState
       Me.txtShipToZip = Me.txtBillToZip

       Me.txtShipToName.Enabled = False
       Me.txtShipToAddress1.Enabled = False
       Me.txtShipToAddress2.Enabled = False
       Me.txtShipToCity.Enabled = False
       Me.txtShipToState.Enabled = False
       Me.txtShipToZip.Enabled = False
Else
       Me.txtShipToName.Enabled = True
       Me.txtShipToAddress1.Enabled = True
       Me.txtShipToAddress2.Enabled = True
       Me.txtShipToCity.Enabled = True
       Me.txtShipToState.Enabled = True
       Me.txtShipToZip.Enabled = True
End If

 and of course making sure that all the controls reference in the above are changed to the names of your actual controls.

  Then in the BeforeUpdate event, check whatever fields you want to ensure they have something in them.

Let us know if you need more detail.

Jim.
0
 
als315Commented:
Jim, I think logic in yiur example is reversed. May be this will be proper sequence:
1. Initially checkbox  [chkShipping] is false and all fields with shipping addresses are disabled.
2. If checkbox  [chkShipping] is changed to true, all shipping fields should be enabled.
Autoupdate sub for checkbox:
Me.[shipping address].Enabled = Not Me.[shipping address].Enabled
Me.[shippin city].Enabled = Not Me.shippin city].Enabled
Me.[shipping state].Enabled = Not Me.[shipping state].Enabled

3. In Merge button's code in first strings:
 if Me.[chkShipping] = false then
     Me.[shipping address] = Me.[exam address]
     Me.[shippin city] = Me.[exam city]
     Me.[shipping state] = Me.[exam state]
endif
........ merge code
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<2. If checkbox  [chkShipping] is changed to true, all shipping fields should be enabled.>>

 Depends on how you label the checkbox:

"Copy Bill To"
"Use Bill To"

vs

"Enter shipping address info"

 and if it is true/false initially as appropriate.  I've seen this coded a bunch of different ways.  Some hide the fields, some allow you to copy the billing info, but still make changes (copy is a button rather then a check box), etc.

Jim.
0
 
ienaxxxCommented:
Yeah i was wrong thinking it was a website... sorry :-)
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 4
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now