I am going to start off and apologise for the length of this post!
I have a form with 9 subforms on. Currently, each subform has its own table. Each of the tables have exactly the same field layout (ie: same fields, but slightly different names for whichever table it is). Here is an example of what I mean:
One table is called ProjectCommercial(PC), another called ProjectTechnical (PT). In these two tables (plus the other 7 tables), 7 fields are identical in each table, and 2 fields are nearly identical (in PT theres a PTID field and a PT field - field with same name as table, and in PC theres a PCID field and a PC field).
I want to normalise this so that there is only one table, and the 9 subforms use this one table. I made a table called BrainstormingTable, and have a TableID field, which will serve to say if its a PT, or PC etc. Part of the reason I want to normalise it is there is a lot of code which is really unnecessary if there is only one table.
Ive made a couple of subforms (placed on a new form) and set them to BrainstormingTable, but I don't know how to add in a row and make the field TableID equal to 1 for example if the subform name is PT. I have named the subform BSPT (stands for BrainstormingProjectTechnical) for the PT part and BSPC for the PC part, with the record source to BrainstormingTable. I tried this code but it doesn't work:
Expand|Select|Wrap|Line Numbers
- Private Sub BrainstormingTableDescription_AfterUpdate()
- If Me.Name = "BSPT" Then
- MsgBox "BSPT"
- ElseIf Me.Name = "BSPC" Then
- MsgBox "BSPC"
- End If
- End Sub
What I noticed is that Me.Name is returning BrainstormingTable, which is the name of the subform when it is opened as a normal form (if that makes sense). What I want is to basically check if the subform name on the main form is equal to BSPT, or BSPC etc and if so then set the TableID field to the correct number (I currently have a msgbox for testing purposes).
Many thanks in advance,
Andrew