Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control reference ...

Status
Not open for further replies.

mtompkins

IS-IT--Management
Jan 14, 2003
166
US
I appologize - I've tried to sort this myself but I just can't.

I've tried the expression builder and the webpage on mvps.org.

In any case.

Form (frmMain)
on which I have
Tab Control (TabCtl0)
on which I have
Tab Roasts (Roasts)
on which I have
Form2 (frmRoasts)
one which I have
Form3 (frmRoastComp)
on which I have
ComboBox (comp)

.... dizzy yet? .. It all looks nice and clean and neat in practice.. anyway

There is a button on frmRoast that when clicked (On Event)
needs to check that the combo box (comp) is has an entry (is not null).

I've tried all I can think of and would appreciate some help.
 
Something like this ?
If Trim(Me!frmRoastComp.Form!comp & "") = "" Then
MsgBox "check that the combo box (comp) is has an entry (is not null)."
Me!frmRoastComp.SetFocus
Me!frmRoastComp.Form!comp.SetFocus
Exit Sub
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV -

Actually, perhaps the problem is caused otherwise.

There is a subform with a frmRoastComp in Datasheet view so it has multiple entries all child records from frmRoast. (They are the different coffees by origin in any given coffee roast.)

I'm trying to ensure that there is at least one entry here.

I'm having the difficulty referring to the subform's control - and perhaps this is being caused because there are multiple "comps" from the Datasheet?

In all cases references come back with

"Compile Error: Variable not yet created in this context".

Additionally I'd like to be able to pull the value of the first entry in the Datasheet's "comp" value for other purposes.
 
Something like this ?
If Me!frmRoastComp.Form.RecordsetClone.RecordCount <= 0 Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Same result - no good.

Additionally this will not pull that first "comp" value.

I do appreciate your efforts.
 
Hi,

Near as I could figure, I rebuilt your design (3 form layers, btn on middle layer, reference to value in bottom layer). using

Code:
Private Sub btnCheck_Click()
    Dim str As String
    
    str = Application.Nz(Me.frmRoastComp!comp)
    Debug.Print Application.Nz(Me.frmRoastComp!comp, "control is empty")
End Sub

behaved as expected. You can put your own messages if the local variable 'str' equals zero-length (ie "").

This differs from PHVs 1st suggestion - there was an extra form reference. Other than that I don't see too many other issues to look for: check the subform is being referenced by it's control name (not necessarily the same as the subform object name), as well as the combobox itself is called 'comp' (eg that it is not named differently to it's source called 'comp')

Please note also this will refer to the last record the focus was on when the user was in frmRoastComp, or the first record if the user has not used the subform. Is this what you want?

Cheers

S
 
It is actually
1 Form (main) with a tab control
One one page of the tab control then a form and subform

I think it is this tab control throwing the wrench in the works...
 
TabControl is neutral for control referencing.
You may play with the expression builder (loaded forms) to discover the correct syntax.
You may also have a look here:

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
SDK


Thank you much - you certainly have sorted the method.

Much appreciated.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top