Results 1 to 3 of 3
  1. #1
    seanp814 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Feb 2016
    Posts
    3

    Autofilling fieldssical

    I have a Client info form that has the following fields:



    Mailing Address1
    Mailing Address2
    Mailing City
    Mailing State
    Mailing Zip

    Physical Address1
    Physical Address2
    Physical City
    Physical State
    Physical Zip

    I have a yes/no checkbox titled Same As Mailing.

    The idea is that when the Same As Mailing box is checked, Access will pull the data from the mailing address fields and place in the physical address fields. I am attempting to accomplish this using an If Then statement on the checkbox's click event.

    I go it to populate, but not unpopulated when the box was unchecked. So I added an Else If to show the Physical fields null if the checkbox was = to false.

    Then the code started getting errors. I have tracked it to my Mailing/Physical State fields, as they are combo boxes so that the user can select the state abbreviation (I know that I can't remember all of them). I have tried the Microsoft help and it tries to explain it, but I'm not getting anywhere.

    Here's the code I've got:

    Private Sub Same_As_Mailing_Click()
    Dim sMailadd1 As String
    Dim sMailadd2 As String
    Dim sMailcity As String
    Dim cbxMailstate As ComboBox
    Dim sMailzip As String
    Dim bSame As Boolean

    sMailadd1 = Me.Mailing_Address1.Value
    sMailadd1 = Me.Mailing_Address2.Value
    sMailcity = Me.Mailing_City.Value
    Set cbxMailstate = Me.Mailing_State.Column(1)
    sMailzip = Me.Mailing_Zip.Value

    If bSame = True Then
    Me.Physical_Address1 = sMailadd1
    Me.Physical_Address2 = sMailadd2
    Me.Physical_City = sMailcity
    Me.Physical_State = cbxMailstate
    Me.Physical_Zip = sMailzip

    End If

    End Sub help would be greatly appreciated.

    Any

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    Is actually easier than you have:

    If me.Checkbox = -1 then
    Me.Physical_Address1 = Me.Mailing_Address1
    etc

    you don't have to Dim and define every field....just a raw copy....

  3. #3
    seanp814 is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Feb 2016
    Posts
    3
    Thank you so much.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Autofilling controls on a form
    By yuvraj.date in forum Forms
    Replies: 13
    Last Post: 09-18-2012, 12:53 PM
  2. Autofilling unwanted feature !
    By Jamescdawson in forum Forms
    Replies: 1
    Last Post: 03-19-2012, 03:16 PM
  3. Autofilling when New Record Created from Form
    By SpdRacerX in forum Forms
    Replies: 6
    Last Post: 01-24-2012, 10:24 AM
  4. Help autofilling a field
    By fullause in forum Access
    Replies: 1
    Last Post: 02-18-2011, 05:54 AM
  5. Replies: 2
    Last Post: 08-05-2010, 12:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums