Ask Experts Questions for FREE Help !
Ask
    gcrutch's Avatar
    gcrutch Posts: 6, Reputation: 1
    New Member
     
    #1

    Nov 3, 2011, 07:54 AM
    how can I Have a value show on a form based on a query
    I have a form it has several text boxes, fields and a subform. It has a parameter that prompts for a SerialNbr.
    The fields on the form are SerialNbr, cboCartStatus, CartDate, CartID, ServiceID
    Subform fields: cboCartEvent, CartID, CartEventSubType, CartEventDate

    The control source for the form is a query that uses the table tbl_Cart. The fields in the tbl_Cart are: CartID, SerialNbr, ServiceID, CartStatus, CartStatusDate
    And the tbl_Cart is related to the tbl_Services and its fields are: ServiceID, AddressID, ServiceStatus, NbrCarts, etc

    The AddressID comes from a view which is the basis for the entire application. So a veiw was created based on the Services table and the vAddress view this is where the vService_Address comes from. It returns all matching records that has an address that's related to a service.

    Hence, what the form does is... when the form is opened it asks the user for a SerialNbr. ONce the serial nbr is entered it brings up the record that is associated with that SerialNbr.


    The following pseudocode was given to me saying this is how I need to do it. Can someone help me turn this pseudocode in to VBA code.

    I have attached a copy of my tables, query and form.

    On the Cart Form, insert an Address label under the “Cart Update” title.
    In the Form Load subroutine, set the default caption to “Address Unknown”.
    Query the Cart table using the Serial Number as the parameter.
    If the query returns a record, check the ServiceID.
    If it is not null, then query view vService_Address using the ServiceID as the parameter.
    Set the Address label to the concatenated address returned by the query
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #2

    Nov 5, 2011, 11:05 AM
    There is an easier way to do this. Add a header to the form. Use the combobox wizard to create a Search combo. You can then enter a serial number to bring up the serial number to retrieve that record.
    gcrutch's Avatar
    gcrutch Posts: 6, Reputation: 1
    New Member
     
    #3

    Nov 7, 2011, 01:29 PM
    I can retrieve the record fine when I enter the serialnbr. In addition to that, I want to be able to see the address as well.
    gcrutch's Avatar
    gcrutch Posts: 6, Reputation: 1
    New Member
     
    #4

    Nov 7, 2011, 01:30 PM
    I basically just need to know how to write the code to
    Do this:
    Query the Cart table using the Serial Number as the parameter.
    If the query returns a record, check the ServiceID.
    If it is not null, then query view vService_Address using the ServiceID as the parameter.
    Set the Address label to the concatenated address returned by the query
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #5

    Nov 7, 2011, 02:17 PM
    Sorry but I'm not clear here. The purpose of subforms is to show related data. When you enter the serial number does the data you want show up on the form someplace? If so, where.

    If all you want to do is print an address label for the associated address, then you need one line of code:

    DoCmd.OpenReport "labelname",, "[AddressID] = " & Me.AddressID
    gcrutch's Avatar
    gcrutch Posts: 6, Reputation: 1
    New Member
     
    #6

    Nov 7, 2011, 02:23 PM
    OK if you were to query a table called Carts using the field called SerialNbr as your parameter how would you write the statement to query that table?
    gcrutch's Avatar
    gcrutch Posts: 6, Reputation: 1
    New Member
     
    #7

    Nov 7, 2011, 02:24 PM
    Everything works fine... I just need to add one more piece of information to the form and that's the Address.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #8

    Nov 7, 2011, 02:43 PM
    Then add a subform to your form, linked on the appropriate field and bound to the address table. If the address field is already a part of the recordsource of either the main form or a subform, then add it as a control.

    A query returns a result set, not a single value. If you want to return a single column from a query for a single record use a DLookup.
    gcrutch's Avatar
    gcrutch Posts: 6, Reputation: 1
    New Member
     
    #9

    Nov 7, 2011, 03:07 PM
    Yes I am returning a result set I guess... the address consist of address, street, suffix. That's why I wanted to concatenate the address returned by the query.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #10

    Nov 8, 2011, 04:39 PM
    If you want to concatenate the address parts, do it in the query, then use the one Query column

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

God is a energy based life form. [ 26 Answers ]

From understanding of the bible. No known life form could have existed before the big bang, not as skin and bone anyway, God must be a energy based life form. Thoughts?

Early 90's Alien based TV show. [ 0 Answers ]

Hi, I've been trying to figure out what this TV show is. I saw it when I was younger. It is an alien based TV shower, I believe only ran for a season or 2. For starters it isn't "Earth Final Conflict." This was a fairly graphic TV show. I believe it was, at least party based in western united...

Microsoft access, parameter query based on form requires all controls to be used? [ 3 Answers ]

Hi, I am trying to run a parameter query from a form in Microsoft access 2010. I am using 7 different combo boxes. The combo box lists are populated from different queries. I was wanting to have the query take the values from the combo box only if the user selected a value form the box. I have...

H1-B/H4 Tax form query [ 3 Answers ]

Hi, I am an Indian Citizen entered US(Dallas, TX) for the first time on 28th July 2007 with H1-B Visa. And my spouse entered US for the first time on Dec 1st 2007 with H4 Visa. I have not changed my visa status to any other visa and I have travelled to India in Nov 2007 for 15 days, came...


View more questions Search