How to create a pre populated list / form view

jex57

Board Regular
Joined
Oct 29, 2015
Messages
62
Hi,
I have a table with pupils names in and a second table with all the tests in.

When I start to enter the data (would have already captured the test details), I would like my form to appear with a list of all the pupil names already showing.

Table with pupil names - ClassId
Table with tests Testid.tha

In my Form header - I have filters in order to select which test I am capturing for or amending.
Once I apply the filter - and there are no test marks available for the class list, I would need to the form to autopopulate the class list.

I have tried to create an append query - but this does not seem to work



Also when I open the form for the initial time - I would like the fields to be hidden until such time as I have applied a filter.
Is there anyway to do this - I could not find an initial event....

Thank you
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I would like my form to appear with a list of all the pupil names already showing.
Either use a form with a subform in data sheet view or a split form. I cannot make any suggestions on the query since I see no linking field in your example.
autopopulate the class list.
I think your query for the datasheet will need an outer join to get names when there are no test marks. Again, guessing by what info you've provided. You do not want an append query for this.
I would like the fields to be hidden until such time as I have applied a filter.
Is there anyway to do this - I could not find an initial event....
On the form Open event. Obviously you will need to be able to access the control that's going to be the trigger, so you don't want to hide that.

Some would say this tag method is slower than other methods but you'll never notice a difference. On each control you want to hide, enter 'HideMe' in the tag on the property sheet (no quotes).
In the form's open event:

Code:
Dim frm as Form
Set frm = Forms![B]yourFormName[/B]
HideControls (frm, True)

When you trigger the event that will show the controls (After_Update?) in that event code type

Code:
HideControls (frm, False)

In a standard module, enter

Code:
Function HideControls (frm As Form, bolShow as Boolean)

On Error Resume Next
For Each ctl In frm.Controls
   If ctl.Tag = "HideMe" Then ctl.Visible = bolShow
Next

End Function

If I've done this air code correctly, you should be able to call the function from any form in this db, regardless of what tag you use in the future. What I have not provided are any lines for error trapping. You might want to figure out where they should go - I don't want to circumnavigate any error handlers you may already be using.
 
Last edited:
Upvote 0
Thanks for the assistance.

With regards to the Class list appearing.

Class Table - has class_ID, name, surname

test Table - Has test_ID, test description

Mark table - has class_id, test_id and then the mark'

Basically what I would like to be able to do is if my test_id in Table Mark is null (not matched to test table).
then autpopulate the class list in the mark table....

Any suggestions would be greatly appreciated
 
Upvote 0
Not enough info for me to help much.
the class list in the mark table
I have no idea what the "class list" is since you don't reference it anywhere else in post #3. If that's the class_ID from class table, please try to keep your references consistent. I should mention two things: if by 'list' you mean a column of or for data, that is a field, not a list. Plus if you really called your table 'Table Mark' I suggest you Google "Access naming convention" before you go too far. Never use spaces in your object names (and I virtually never use the underscore. I find it cumbersome).

Anyway, I see no way to do what you want. If test id in table mark is null, then what is common between them? If nothing, then you have nothing to base your changes on. How would we know how many rows to 'auto populate'? It's kind of like asking the child to create the parent.
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,252
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top