MS Access Forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Newbie23
    New Member
    • Jan 2009
    • 25

    MS Access Forms

    Hi All,

    Im currently trying to develop a small customer database but keep coming up against loads of little problems.

    At the minute I have a form with a data sheet at the bottom listing all customers and at the top are a few boxes that is populated when the user selects a record in the data sheet... If that makes any sense?!

    I would like to be able to open another form, based on the record that is selected, that will show an account summary as if were. It will be a select only form that will show all the customer details. I have tried this by using the following code:
    Code:
        stDocName = "frm_accSummary"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
        Forms("frm_accSummary")![AccID] = AccID
    However I get the message "You can't assign a value to this object"

    All I want is for the user to be able to search for a customer then open a account summary form, Any Ideas?

    Many Thanks
    Jane
    Last edited by NeoPa; Apr 6 '09, 01:05 PM. Reason: Please use the [CODE] tags provided
  • ChipR
    Recognized Expert Top Contributor
    • Jul 2008
    • 1289

    #2
    Code:
    "[AccID] = " & AccID
    This should be part of the WhereCondition. It would be included in the stLinkCriteria.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32661

      #3
      Chip's answer will help you do it manually Jane.

      I suggest that, as a fairly new user of Access, you may find some help playing with some of the many wizards that Access has available for you. I'm pretty sure there's one to do this sort of thing for you. You will probably see that it uses example code just as Chip has shown.

      It's well worth bearing in mind for other issues you may have too.

      Welcome to Bytes!

      Comment

      • Newbie23
        New Member
        • Jan 2009
        • 25

        #4
        Yeah I have used the wizzad to do this sort of thing before, However for some reason it wont work on th database. Where the wizzard asks to pick from two fields that will match, one of the columns is always empty and wont they you continue.

        Anyway, Im not sure I understand about how to amend the code I posted before?

        Many thanks for your help

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          You would have to make sure stLinkCriteria was prepared beforehand, so (line#1 from Chip's post) add :
          Code:
          stLinkCriteria = "[AccID]=" & Me.AccID
          before line #2 from your original post. Line #3 from there can be removed.

          Hope that helps.

          Comment

          • ChipR
            Recognized Expert Top Contributor
            • Jul 2008
            • 1289

            #6
            In the code you posted before, stLinkCriteria is the variable that contains the WhereCondition argument to the OpenForm Method. What have you set stLinkCriteria to right now? If you don't have any other conditions to filter the form, you might use:
            Code:
            DoCmd.OpenForm "frm_accSummary", , , "[AccID] = " & AccID
            Note that this assumes AccID is numerical. Text fields require apostrophes ( ' ' ) around them, and would look like:
            Code:
            ..."[AccID] = '" & AccID & "'"

            Comment

            Working...