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

Access form and subform assistance needed

P: 5
I am in need of assistance with an Access form. On my form I have a combo box and I would like the datasheet subform to populate with the data that is associated with my combo box selection. I know how to requery the data so that I get a dropdown list of the associated data but that is not ideal. Any assistance would be appreciated.
Jul 12 '07 #1
Share this Question
Share on Google+
8 Replies


hyperpau
Expert 100+
P: 184
I am in need of assistance with an Access form. On my form I have a combo box and I would like the datasheet subform to populate with the data that is associated with my combo box selection. I know how to requery the data so that I get a dropdown list of the associated data but that is not ideal. Any assistance would be appreciated.

is your subform datasheet bound to a query or to a table?
it should be bound to a query then you just have to put a parameter which is equivalent to the value selected on your combobax.

Example:
you chose Record 1 on your combobox, then you want the datasheet subform
to show the data for Record 1 as well.
Then you put parameters to the query where the datasheet subform is bound.


Let's say your query has the Fields 'RecordNo' and 'RecordData'.
You go to the design view of the query and put this as a criteria

=Forms![Name of the Form]![Name of the combobox]

Then on the VBA code of the combobox, put these:

Private Sub NameOfComboBox_AfterUpdate()

Me![Name of subform].Requery

End Sub
Jul 12 '07 #2

P: 5
my subform datasheet was bound to a table. But I changed it so it is bound to the query like you suggested. I entered the parameter as suggested and put in the VBA code. Unfortunately, it is still just giving me a drop down list with the related information and not automatically populating the datasheet.
I am going to insert an image of what I would like it to look like to give you an idea. I had to go in and manually select all of the criteria you see in the Error column. I dont want to have to do that.
Attached Images
File Type: jpg errorList.jpg (46.2 KB, 200 views)
Jul 12 '07 #3

hyperpau
Expert 100+
P: 184
my subform datasheet was bound to a table. But I changed it so it is bound to the query like you suggested. I entered the parameter as suggested and put in the VBA code. Unfortunately, it is still just giving me a drop down list with the related information and not automatically populating the datasheet.
I am going to insert an image of what I would like it to look like to give you an idea. I had to go in and manually select all of the criteria you see in the Error column. I dont want to have to do that.
On this image that you posted, which of the combo box in the main form
will be selected to populate the datasheet subform? is the task or the task detail?

however, i don't see any fields in the subform datasheet that matches
the values in any of the 2 comboboxes. there should be at least one matching
field in order for this to work
Jul 23 '07 #4

P: 5
On this image that you posted, which of the combo box in the main form
will be selected to populate the datasheet subform? is the task or the task detail?

however, i don't see any fields in the subform datasheet that matches
the values in any of the 2 comboboxes. there should be at least one matching
field in order for this to work

The way my tables are set up is that task is related to task detail and task detail is related to Error.
Therefore, once the task detail is selected I would like the subform to populate with the Error related to that task detail. Does this make sense? Was there more info you needed to assist with this? Thanks for your help so far!
Jul 26 '07 #5

hyperpau
Expert 100+
P: 184
The way my tables are set up is that task is related to task detail and task detail is related to Error.
Therefore, once the task detail is selected I would like the subform to populate with the Error related to that task detail. Does this make sense? Was there more info you needed to assist with this? Thanks for your help so far!
sorry for the long wait.
The way I see it, you have to make sure that there are Primary and foreign key relationship between the task detail and Error, assuming they belong to two different tables.

let's say your task detail table should have a Primary Key named TaskDetailID, therefore your error table should have as well a Primary Key name TaskDetailID. Then you create a relationship with the two. now that they are related, you can quickly relate the error subfrom to your taskdetail form by using the TaskDetailID field as the Parent and Child Link Fields. You can do that by going to the design view of your form and pulling up the properties of your subform.

Again, the properties of the subform as a subform of the mainform. You can do that by double clicking the border of the subform instead of its form selector. Go to the Data Tab and choose TaskDetailID as the Parent Link and for Task Detail table, and TaskDetailID as the Child Link for the Error table.

does this make any sense to you?
Aug 1 '07 #6

P: 5
sorry for the long wait.
The way I see it, you have to make sure that there are Primary and foreign key relationship between the task detail and Error, assuming they belong to two different tables.

let's say your task detail table should have a Primary Key named TaskDetailID, therefore your error table should have as well a Primary Key name TaskDetailID. Then you create a relationship with the two. now that they are related, you can quickly relate the error subfrom to your taskdetail form by using the TaskDetailID field as the Parent and Child Link Fields. You can do that by going to the design view of your form and pulling up the properties of your subform.

Again, the properties of the subform as a subform of the mainform. You can do that by double clicking the border of the subform instead of its form selector. Go to the Data Tab and choose TaskDetailID as the Parent Link and for Task Detail table, and TaskDetailID as the Child Link for the Error table.

does this make any sense to you?
Most of what you are saying is making sense. I almost think I already have that going on. I would like to get you a copy of the database so you can look at it. Just the screen print alone was not adequate to get a clear picture. I am not sure if there is a way to attach it here. Let me know if you know of a way for me to do that.
Aug 1 '07 #7

hyperpau
Expert 100+
P: 184
Most of what you are saying is making sense. I almost think I already have that going on. I would like to get you a copy of the database so you can look at it. Just the screen print alone was not adequate to get a clear picture. I am not sure if there is a way to attach it here. Let me know if you know of a way for me to do that.
send me an email and attach it there. my user preference here in the scripts is set to accept emails. :)
Aug 2 '07 #8

P: 5
Looks like it isnt set up to receive emails at this time.
Aug 7 '07 #9

Post your reply

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