By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,480 Members | 2,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,480 IT Pros & Developers. It's quick & easy.

Adding a new record in a form problem

P: 5
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.
Feb 21 '07 #1
Share this Question
Share on Google+
6 Replies


Rabbit
Expert Mod 10K+
P: 12,315
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.
Feb 21 '07 #2

P: 5
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
Feb 22 '07 #3

Rabbit
Expert Mod 10K+
P: 12,315
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:
Expand|Select|Wrap|Line Numbers
  1. Filter = ((tbl_Data.[Client Name] = "Bob"))
You should be able to pull that substring out, i forget the exact function.
Feb 22 '07 #4

NeoPa
Expert Mod 15k+
P: 31,186
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:
Expand|Select|Wrap|Line Numbers
  1. 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.
Expand|Select|Wrap|Line Numbers
  1. Dim strName As String
  2. Dim intQPos As Integer
  3.  
  4. intQPos = InStr(1,Me.Filter,"""")
  5. strName = Mid(Me.Filter,intQPos)
  6. intQPos = InStr(1,strName,"""")
  7. strName = Left(strName,intQPos-1)
Feb 23 '07 #5

P: 5
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
Mar 11 '07 #6

NeoPa
Expert Mod 15k+
P: 31,186
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 :)
Mar 11 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.