I get error with this sub...Seems to be somewhere in my DLookup code.
I do not get much further...
Some comments below, but really you need to supply the actual error
message and the line it occurs on...
Sub PUMPlabeling(ByVal i As Integer)
Very old-style declaration; not incorrect but it's clearer and
more likely to avoid problems by using Dim hNumber as String
Hnumber = "lbHnumber" & i
Safer to use explicit Format expression: with low values this is
obviously okay, but with large numbers you may find yourself faced with
an expression like "lbHnumber1.34E4" or whatever.
See above. Dim strValSelected As String
valSelected = Me.Controls("cboH" & i).Value
Remember that any Textbox.Value can be a Null -- therefore it's safer to
catch this either with a Nz() function or using a Variant.
There is a comma at the end of this: this should not even pass the editor
without flagging the error. Again, if it is picking up a DLookup() it
should be capable of accepting a Null, so use a Variant instead.
valnumber = DLookup("[Hnumber]", "H_system", _
"[Hnumber] =" & valSelected)
I don't see the point of passing a hNumber value and asking for the same
thing back. There are only two possible returns from this lookup: either
Null (there is no such Hnumber) or Hnumber itself (which you already
know). If it's Null, then the command will fail because valnumber is
declared as a string. I suggest you change this to something like
dim fNotThere as Boolean
fNotThere = (0 = DLookup("Hnumber", "h_system", _
"Hnumber=" & valSelected)
You don't seem to be doing anything with this value anyway. The call to
FillInLabel uses the same value as valSelected.
Another potential problem: I note that you are using a string variable
for valSelected, although I guess that Hnumber is a numeric. It is is in
fact a text field, you need to quote the thing properly:
"Hnumber=""" & valSelected & """"
but if it's a number then the expression is fine as it is.
FillinLABEL Hnumber, valnumber
End Sub
FilinLABEL is just a Sub filling in values in labels.
This is not spelled the same as the call above: which one is the typo?<g>
Hope that helps. Please post again with the actual error information if
you need further advice.
Best wishes
Tim F