AccessChap
Registered User.
- Local time
- Today, 20:01
- Joined
- Apr 14, 2009
- Messages
- 32
Morning all! Yes, I'm afraid it's me again although I have been away for an encouraging length of time haven't I? 
Got what I suspect is a simple question of syntax so I'm hoping a kind soul will be able to point out the correct notation for my command and away I'll go.....
What I'm trying to do is reference a field on a subform from a function that is call when I click a button on the parent form. The problem is that depending on a combo box value on the parent form I may be using one of two subforms. So I need the function to inspect the field on the relevant subform only. I start off with my call to the function thusly:
Dim strFranchise as string
strFranchise = Me.lstFranchise
myFunction(strFranchise)
All well and good so far and as an example the strFranchise will contain "PEU" or "CIT" at this moment (Peugeot or Citroen manufacturers)
Inside myFunction is this line:
myVariable = Me.frm_Subform.Controls(abc)
Don't worry about the abc variable, that's just a counter for a loop as there are lots of checkboxes to be vetted on the subform. The part that I can't code correctly is the frm_Subform. Obviously if I replace this with the subform's literal name then all is well but I can't handle two or more subforms
What I want to be able to do is replace the frm_Subform automatically with the relevant form name. All the subforms have a common naming convention starting with ftm_stub_ and then ending with a three letter franchise designator i.e. "PEU" or "CIT". I suppose what I want is a command like:
myVariable = Me.frm_stub & strFranchise & .Controls(abc)
but that produces a compile error. I clearly don't have the correct syntax
Anyone able to correct my syntax?
Any help gratefully received,
Andy

Got what I suspect is a simple question of syntax so I'm hoping a kind soul will be able to point out the correct notation for my command and away I'll go.....
What I'm trying to do is reference a field on a subform from a function that is call when I click a button on the parent form. The problem is that depending on a combo box value on the parent form I may be using one of two subforms. So I need the function to inspect the field on the relevant subform only. I start off with my call to the function thusly:
Dim strFranchise as string
strFranchise = Me.lstFranchise
myFunction(strFranchise)
All well and good so far and as an example the strFranchise will contain "PEU" or "CIT" at this moment (Peugeot or Citroen manufacturers)
Inside myFunction is this line:
myVariable = Me.frm_Subform.Controls(abc)
Don't worry about the abc variable, that's just a counter for a loop as there are lots of checkboxes to be vetted on the subform. The part that I can't code correctly is the frm_Subform. Obviously if I replace this with the subform's literal name then all is well but I can't handle two or more subforms
What I want to be able to do is replace the frm_Subform automatically with the relevant form name. All the subforms have a common naming convention starting with ftm_stub_ and then ending with a three letter franchise designator i.e. "PEU" or "CIT". I suppose what I want is a command like:
myVariable = Me.frm_stub & strFranchise & .Controls(abc)
but that produces a compile error. I clearly don't have the correct syntax

Any help gratefully received,
Andy