Yes we are using Form Designer 5.0. The objects I'm using are Drop Down List Boxes.
I didn't know about the DropOnEnter=True property (I'm kind of new at this) but that works well if I have a Choice List typed under List in the properties of the object, but if I run a query in code it doesn't work. If, in the properties, I change the DropOnEnter=True I need to also change the DropDownStyle to DropDownList (according to something I read). If I do that, it works perfect when I have a choice list but the drop down list won't even display with a mouse click for the db query. If I have the DropDownStyle set to DropDown Combo, the list will display from the query when I enter the field, but when I leave the field after pressing Enter to select one item, the data disappears.
I have tried playing with different settings under Properties as well as looking at the code under the onExit and DropDownClick events for the object but am not sure.
Here is the code under the two events which might give you some insight. I tried playing with the defaultselection and currentselection but as of yet haven't gotten it to work.
It would be great if it worked just like it does with the Choice List.
OnDropDownClick
Dim oRS
Dim strList
Dim szSQL
psrelcode.Clear()
If (psrelcode.ListCount = 0) then
if rbbus.Value = rbbus.OnValue then
szSQL = "Select reldesc,relcode from relate where relcode = 'ADV' OR relcode = 'AKA' OR relcode = 'SUB' OR relcode = 'PAR' OR relcode = 'FKA' order by reldesc"
Set oRS = WFDataClient.ConvertToRecordset(WFDataClient.ExecuteReturnDataSetWithConnName(szSQL,"conn_son2"))
else
rbindiv.Value = rbindiv.OnValue
szSQL = "Select reldesc,relcode from relate where relcode = 'ADV' OR relcode = 'OC' OR relcode = 'PTR' OR relcode = 'PADV' OR "_
& "relcode = 'SP' OR relcode = 'EXPW' OR relcode = 'FKA' OR relcode = 'HEIR' OR relcode = 'TRUST' OR relcode = 'COOWN' OR "_
& "relcode = 'DIR' OR relcode = 'PRINC' OR relcode = 'CODEF' OR relcode = 'COCSL' order by reldesc"
Set oRS = WFDataClient.ConvertToRecordset(WFDataClient.ExecuteReturnDataSetWithConnName(szSQL,"conn_son2"))
End if
Do Until oRS.EOF
strList = strList & Trim(oRS(0)) & ";" & Trim(oRS(1)) & vbNewline
oRS.MoveNext
Loop
psrelcode.ChoiceList = strList
psrelcode.DefaultSelection = 0
End if
OnExit
Dim oRS
Dim strList
Dim szSQL
psrelcode.Clear()
form.BusyCursor = True
If (psrelcode.Text <> "") Then
szSQL = "Select reldesc,relcode from relate where reldesc = '" & psrelcode.Text & "'"
Set oRS = WFDataClient.ConvertToRecordset(WFDataClient.ExecuteReturnDataSetWithConnName(szSQL,"conn_son2"))
If (oRS.recordCount > 0) then
if (oRS.RecordCount = 1) then
psrelcode.Text = Trim(oRS(0) & "")
ReCode.Text = Trim(oRS(1) & "")
psrelcode.DropDownStyle=1
else
psrelcode.Text=""
ReCode.Text = ""
end if
Else
psrelcode.Text = ""
ReCode.Text = ""
form.BusyCursor = False
msgbox "No records found matching your criteria. Please try again.",vbinformation,"Relationship Lookup"
form.GoToField(psrelcode)
End if
Else
psrelcode.Text=""
ReCode.Text = ""
End if
psrelcode.CurrentSelection = 0
form.BusyCursor = False
Thank you in advance.
Mary