Mike Eghtebas
asked on
combo box with UserDefined function and wrong ...
I have a cmbo box with fnVin in its RowSourceType (nothing in its RowSource) which populates the combo box.
When an item is selected from the dropdown, it shows some other value (from the same field). Why it doesn't display what user selects. For example, when user select 5, it shows 7 or some other number.
Function fncboVin(fld As Control, id As Variant, row As Variant, col As Variant, code As Variant) As Variant
'On Error Resume Next
Dim ReturnVal As Variant
ReturnVal = Null
Select Case code
Case acLBInitialize ' Initialize.
Entries = 0
Entries = Entries + 1
.
.
.
End Select
fncboVin = ReturnVal
End Function
Code works fine because it populate the combo box ok. Is there some setting
Thanks
When an item is selected from the dropdown, it shows some other value (from the same field). Why it doesn't display what user selects. For example, when user select 5, it shows 7 or some other number.
Function fncboVin(fld As Control, id As Variant, row As Variant, col As Variant, code As Variant) As Variant
'On Error Resume Next
Dim ReturnVal As Variant
ReturnVal = Null
Select Case code
Case acLBInitialize ' Initialize.
Entries = 0
Entries = Entries + 1
.
.
.
End Select
fncboVin = ReturnVal
End Function
Code works fine because it populate the combo box ok. Is there some setting
Thanks
ASKER
Hi (°v°),
Function fncboVin(fld As Control, id As Variant, row As Variant, col As Variant, code As Variant) As Variant
On Error GoTo Errs
Dim ReturnVal As Variant
ReturnVal = Null
Select Case code
Case acLBInitialize ' Initialize.
Entries = 0
Entries = Entries + 1
ReturnVal = Entries
Case acLBOpen ' Open.
ReturnVal = Timer
Case acLBGetRowCount ' Get number of rows.
ReturnVal = lngRowVin
Case acLBGetColumnCount ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWidth ' Column width.
Case acLBGetValue
ReturnVal = rsVin!VIN 'dbs(row)
'MsgBox VarType(rsVin!VIN)
'If Entries = lngRowVin Then
'End If
If Entries < lngRowVin Then
rsVin.MoveNext
Else
rsVin.MoveFirst
End If
Case acLBEnd ' End.
End Select
fncboVin = ReturnVal
On Error Resume Next
Forms!fSearch!lblVinQty2.C aption = Entries 'to see if Entries matches lngRowVin
Forms!fSearch!lblVinQty.Ca ption = lngRowVin ' on the form
Forms!fSearch.Repaint
Exit Function
Errs:
'SeRs just sets rsVin again, it becomes some how it losses it
If Err.Number = 91 Or Err.Number = 3021 Then
rsVinYN = False
Forms!fSearch.SeRs
Else
MsgBox Err.Description
End If
Resume Next
End Function
I suspect, my code has some problem. It doesn't return the same set consistantly. In the past I was very good with UserDefined functions. I guess I am a bit rusty.
It is a real pleasure to hear/read from you. Now, I know I am at good fnags, LOL.
Will check back in a couple of hours.
Thanks,
Mike
Function fncboVin(fld As Control, id As Variant, row As Variant, col As Variant, code As Variant) As Variant
On Error GoTo Errs
Dim ReturnVal As Variant
ReturnVal = Null
Select Case code
Case acLBInitialize ' Initialize.
Entries = 0
Entries = Entries + 1
ReturnVal = Entries
Case acLBOpen ' Open.
ReturnVal = Timer
Case acLBGetRowCount ' Get number of rows.
ReturnVal = lngRowVin
Case acLBGetColumnCount ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWidth ' Column width.
Case acLBGetValue
ReturnVal = rsVin!VIN 'dbs(row)
'MsgBox VarType(rsVin!VIN)
'If Entries = lngRowVin Then
'End If
If Entries < lngRowVin Then
rsVin.MoveNext
Else
rsVin.MoveFirst
End If
Case acLBEnd ' End.
End Select
fncboVin = ReturnVal
On Error Resume Next
Forms!fSearch!lblVinQty2.C
Forms!fSearch!lblVinQty.Ca
Forms!fSearch.Repaint
Exit Function
Errs:
'SeRs just sets rsVin again, it becomes some how it losses it
If Err.Number = 91 Or Err.Number = 3021 Then
rsVinYN = False
Forms!fSearch.SeRs
Else
MsgBox Err.Description
End If
Resume Next
End Function
I suspect, my code has some problem. It doesn't return the same set consistantly. In the past I was very good with UserDefined functions. I guess I am a bit rusty.
It is a real pleasure to hear/read from you. Now, I know I am at good fnags, LOL.
Will check back in a couple of hours.
Thanks,
Mike
ASKER
Longh day here
good fangs is correct.
good fangs is correct.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How can have text A+ appear like A° (+ in the place of °)
Mike
Mike
> How can have text A+ appear like A°
I do not understand. Do you mean: Replace(strSomeText, "°", "+") ???
(°v°)
I do not understand. Do you mean: Replace(strSomeText, "°", "+") ???
(°v°)
- displays a list (one or several columns)
- translates a code to text (e.g. bound column is hidden)
- allows user-editing
- translates text back to a code (again for a hidden bound column)
If the list is displayed, it does not mean that your function really works as intended. Try first with bound column = 0, or at least without any hidden columns.
Else, I guess we will need the full function, and the relevant properties of the combo box, namely bound column and column widths.
Cheers!
(°v°)