Adding a new record in a form problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • paulcrowsnest
    New Member
    • Feb 2007
    • 5

    #1

    Adding a new record in a form problem

    I have a master form (clients), and 2 subforms (invoice and credit account details). This all works great.
    ive added a command button in the master form (clients) to open a new form as a popup where i can view information about the credit payment history, when i created the command button i used the "open the form and find specific data to display" option, i then linked the new form to only display data that is relevent to the master form(clients) data currently displayed. Again this works fine, the popup form only shows these filtered records.
    My problem is, when i goto add a new record all the filtering is lost and i have to use the combo box, with its list of names, to get the relevent client name again, i knew it would do this, but what i dont know is how can I force the combo box to display the clients name that is being used on the filtered popup form.
    It realy has me stumped, i dont want to take the chance that the end-user puts in the wrong client name.
    Any help would be well appreciated, and i can then get a good nights sleep.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    I suppose you can extract the client name that is being used in the filter and use that to fill in the name for your new record. You could also lock the field to prevent people from tampering with it.

    Comment

    • paulcrowsnest
      New Member
      • Feb 2007
      • 5

      #3
      Cheers Rabbit, although i do a fair bit of VB etc in web design ASP.net, i am quite new to Access, and i have found lots of info on the net to help me along, but again, my problem is that when you say extract the filtered name from the form, i go derrrr, what does that mean and how do i do that, if you could expand on that statement i would be grateful. i will look tho to see if i can figure it out based on your comments, cheers

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Well, if there is a filter on the form. Then the form's Filter property will have the string statement that filter's it. Something along the lines of:
        Code:
        Filter = ((tbl_Data.[Client Name] = "Bob"))
        You should be able to pull that substring out, i forget the exact function.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32669

          #5
          Originally posted by Rabbit
          Well, if there is a filter on the form. Then the form's Filter property will have the string statement that filter's it. Something along the lines of:
          Code:
          Filter = ((tbl_Data.[Client Name] = "Bob"))
          You should be able to pull that substring out, i forget the exact function.
          If your filter (Me.Filter) is of the form described by Rabbit, then some code along the lines of the following should extract the value out of it. I'm searching for the (") char (Better to use (') in SQL strings though) and using its positions to formulate the string.
          Code:
          Dim strName As String
          Dim intQPos As Integer
          
          intQPos = InStr(1,Me.Filter,"""")
          strName = Mid(Me.Filter,intQPos)
          intQPos = InStr(1,strName,"""")
          strName = Left(strName,intQPos-1)

          Comment

          • paulcrowsnest
            New Member
            • Feb 2007
            • 5

            #6
            Thanks guys for the help, sorry for the delayed response, been away (got Married :(

            Because the subform is linked to the mainform via ClientID i found that if i present the subform with "Data-Allow Additions" set to True it automatically inserted the ID into the subform for me i then just added the other data fields and added the new record, i stumbled on it by accident on another form i was working on, it seems to do what i want.
            thanks again for your assistance, it is appreciated

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32669

              #7
              Originally posted by paulcrowsnest
              Thanks guys for the help, sorry for the delayed response, been away (got Married :(

              Because the subform is linked to the mainform via ClientID i found that if i present the subform with "Data-Allow Additions" set to True it automatically inserted the ID into the subform for me i then just added the other data fields and added the new record, i stumbled on it by accident on another form i was working on, it seems to do what i want.
              thanks again for your assistance, it is appreciated
              No problem - glad you found a good solution.
              Congratulations on your nuptials btw :)

              Comment

              Working...