We help IT Professionals succeed at work.
Get Started

Text boxes don't display data until you click on them

SteveL13
SteveL13 asked
on
144 Views
Last Modified: 2015-03-11
I have two text boxes on a form that get their data from two modules.  The data has always display in the past but for some reason just today they don't display the data unless the user clicks on the field(s).

Has anyone ever run into this before?

I am copy/pasting the module code below just for reference.

The control source for the 1st field is:

=getLevels(Forms("frmJobCards").[txtPartN])

and the module code is:

Function getLevels(inPart As String) As String
On Error GoTo myErr

    Dim rs As New ADODB.Recordset
    Dim strCat As String
    strCat = ""
    Dim selectCommand As String
        selectCommand = "SELECT DISTINCT [Core Sand Type] as CST FROM tblCbxNumberData WHERE PartN = " & """" & inPart & """"
    
rs.Open selectCommand, CurrentProject.Connection

'Get the types
Do While rs.EOF = False
    strCat = strCat & rs("CST") & "/"
        rs.MoveNext
Loop
rs.Close

If Len(strCat) > 0 Then

'Reorder if needed
    If InStr(1, strCat, "Expert/") >= 1 Then
        strCat = Replace(strCat, "Expert/", "")
        strCat = "Expert/" & strCat
        
    End If
    
    'Remove the last slash
    strCat = Left(strCat, Len(strCat) - 1)
End If

getLevels = strCat

Exit Function
myErr:

getLevels = strCat

End Function

Open in new window



The control source for the 2nd field is:

=getLocations(Forms("frmJobCards").[txtPartN])

and the module code is:

Function getLocations(inPart As String) As String
On Error GoTo myErr

    Dim rs As New ADODB.Recordset
    Dim strCat As String
    strCat = ""
    Dim selectCommand As String
        selectCommand = "SELECT DISTINCT [Loc] as CST FROM tblCbxNumberData WHERE PartN = " & """" & inPart & """"
    
rs.Open selectCommand, CurrentProject.Connection

'Get the types
Do While rs.EOF = False
    strCat = strCat & rs("CST") & "/"
        rs.MoveNext
Loop
rs.Close

If Len(strCat) > 0 Then

    
    'Remove the last slash
    strCat = Left(strCat, Len(strCat) - 1)

Else
    strCat = ""  'replaced NoValue
End If

getLocations = strCat

Exit Function
myErr:

MsgBox Err.number & " - " & Err.Description   'add this line in getLocations  function

getLocations = strCat

End Function

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE