Results 1 to 15 of 15
  1. #1
    nchesebro's Avatar
    nchesebro is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Posts
    108

    Country Code Calculation


    I am working on the address portion of my database now.

    I have a listing of all USA States, Canadian Provinces/Territories, and Mexican State Abbreviations from http://www.iowa.gov/tax/forms/84055.pdf

    When a user is completing this particular form, they will enter the city, state, and zip. (I know I can get zip codes too, but our organization lacks the funds and resources to maintain an up to date listing at all times for that option to be practical) When they select the state/province abbreviation from a lookup box, I would like a calculated field to associate the appropriate three digit country code (aka, USA, CAN, or MEX).

    I am not real experienced in calculated fields, any pointers?

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    I would probably do this with a Case Select Statement in VBA

    Here is information on that

    http://www.databasedev.co.uk/select-case-statement.html

    Alan

  3. #3
    nchesebro's Avatar
    nchesebro is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Posts
    108
    Would the information in that source also apply to this situation:

    When a student calls in to make a tour reservation, they are asked what programs they are interested in. They may ask for some program that we do not have or an incorrect program-degree type. Therefore, in the reservation form, the inputter will select either Master, Bachelor, or Associate, and the selection there would trigger a query to find all programs in that degree class and populate another drop down menu with the appropriate programs per the selected degree.

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    have you reviewed the site

  5. #5
    nchesebro's Avatar
    nchesebro is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Posts
    108
    I have. It will take some time for me to figure out how to make that source material apply to the first situation, but I think it would be inappropriate to try to use the same thing for the second scenario. For the second scenario, I think the use of queries would be more suitable...

  6. #6
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    The second scenario is called cascading combo boxes. Here is a tutorial on them.

    http://www.fontstuff.com/access/acctut10.htm

    You may also want to look at this site and view the tutorials on combo boxes.

    http://www.datapigtechnologies.com/AccessMain.htm

    Alan

  7. #7
    nchesebro's Avatar
    nchesebro is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Posts
    108
    Okay, so I was sucessfull at creating the cascading combo boxes, once. The second instance I was not. If you open my database, go on to the frmReservation, and scroll to the bottom half where you will see an area titled Ticket Requests. You can select a ticket type (ie Meal or Athletic) but the second combo box does not populate with anything. Maybe it was a simple simple mistake in my vb code behind and I continue to overlook it, or maybe it has something to do with the way the form itself is structured? What I do know for sure though is that I have exhausted every technique I know to resolve the issue and it isnt working .

    Also, on a side note, at the top of the form, you can select a State/Province. I have tables and relationships set up to determine what state/province belongs to what country and have a query set up that should update the Nation field to the appropriate country code after the state is selected, and that too will not work, despite the same type of thing working for the Date/Day calculation... Stumped again.

    I appreciate your help

  8. #8
    nchesebro's Avatar
    nchesebro is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Posts
    108
    ...and here is the database (whoops)

  9. #9
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Did you make sure to change the Combo's COLUMN COUNT property to be the right number of columns and refer to the column right (zero-based)?

    I can't download and look at your db right now, so I just thought I would throw those ideas out there for you.

  10. #10
    nchesebro's Avatar
    nchesebro is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Posts
    108
    It was initially set to 1, changed it to 0, no luck there...

  11. #11
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by nchesebro View Post
    It was initially set to 1, changed it to 0, no luck there...
    Column Count is not zero based. So if you have 2 columns it needs to be set at 2. It was the reference of

    =[ComboNameHere].[Column](1)

    that I was referring to as far as zero-based numbering (where the example would be the second column).

  12. #12
    nchesebro's Avatar
    nchesebro is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Posts
    108
    I have the Combo based on either one of two single column queries, which is determined based on the selection of the first combo box.

    "=[ComboNameHere].[Column](1)"

    Where would i find that expression at? I cant find one that resembles that other than that in the row source of the determining combo box...

  13. #13
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    I just thought of something. Did you make sure to Requery the second combo box in the After Update event of the first?

    (and you can ignore the other stuff I said, as it appears not to be applicable)

  14. #14
    nchesebro's Avatar
    nchesebro is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2010
    Posts
    108
    Maybe it is in the wrong spot in the code? Just checked that and in fact that was absent. Still not working though... maybe I have it in the wrong place?

    Private Sub cboTicket_AfterUpdate()
    Me.cboType.Requery
    On Error Resume Next
    Select Case cboTicket.Value
    Case "Athletic Tickets"
    cboType.RowSource = "qryAthleticTickets"
    Case "Meal Tickets"
    cboType.RowSource = "qryMealTickets"
    End Select
    End Sub

  15. #15
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Yep, wrong place. It should be after.
    Code:
    Private Sub cboTicket_AfterUpdate()
    
    Select Case cboTicket.Value
       Case "Athletic Tickets"
          cboType.RowSource = "qryAthleticTickets"
       Case "Meal Tickets"
          cboType.RowSource = "qryMealTickets"
    End Select
       
       Me.cboType.Requery
    
    End Sub
    And I would get rid of the ON ERROR RESUME NEXT because that can obscure some problems that might be underlying things.

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

Similar Threads

  1. BMI calculation
    By puush in forum Programming
    Replies: 9
    Last Post: 08-19-2014, 05:05 AM
  2. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  3. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  4. Calculation Help
    By ErnieS in forum Access
    Replies: 13
    Last Post: 07-08-2010, 08:35 AM
  5. Calculation
    By thestclair in forum Reports
    Replies: 1
    Last Post: 04-29-2006, 11:03 AM

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