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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Labels as Arguments

Status
Not open for further replies.

GsyDonkey

Technical User
Jul 4, 2002
4
GB
Hello,

I'm trying to pass a label as an argument as I have to correct a lot of labels on an access form.

The method is called thus:

Interaction.setLbl Me.partyInfoLabel, partyName

(btw - partyInfoLabel is a label and partyName is a string)

and the method itself looks like this:

Sub setLbl(lbl As Label, val As String)
lbl.Caption = val
End Sub

The error message informs me that there is a type mismatch. I have tried setting ByRef argument, defining lbl as a control, defining lbl as a variant and defining lbl as an object, but I can't seem to put my finger on the 'magic solution'. Is there anyone there who can simply look at this and give me an instant solution?

Thanks,

:S
 
Why don't you just get rid of your setLbl sub and do it inline?
Me.partyInfoLabel.caption = partyName

not much extra typing!

b
----------------------------------
Ben O'Hara
bo104@westyorkshire.pnn.police.uk
----------------------------------
 
Well, there is that....ooops!

I'd imagine that's why access doesn't support it - knowing Microsoft.

Only trouble is that there are other methods I've made within the Interaction class which have optional label arguments (together with their strings), whereby the label is set based on a concatenation of the string in the called method with the string value it is passed.

i.e. Interaction.setPty Me.listbox1, "Party", "ID", Me.partyLabel, Me.cltNo

Sub setPty(lstBx as listbox, tbl1 as string, tblref as string, lbl as label, val as string)
lstBx.rowsource = "SELECT.....(blah blah blah)
lbl.caption = "Notes relating to Party " & val
End Sub

As I call the setPty method to populate list boxes, and set their labels, it makes sense to send it as an argument in this case as there is extra data added.

What do you reckon?
 
Um...rather embarassing...

Just found out that I'd been using textBoxes and not labels. That would explain it.

Sorry :$
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top