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

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

SteveL13Asked:
Who is Participating?
 
SteveL13Author Commented:
Ok.   Nobody may believe this but the computer that had the problem was in need of a Windows or Office update.  Once the updates were installed the problem went away.

--Steve
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can always force the update in the Form's Current event:

Me.YourTextbox = getLocations(Me.txPartN)

That said - calling functions in your event stubs is just poor programming, IMO. If your application is correctly built, with properly normalized tables, you will find your needs for these sorts of crutches to be very, very few.
0
 
Jeffrey CoachmanMIS LiasonCommented:
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)
...and to be sure, ...run the compact repair utility...
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
SteveL13Author Commented:
I tried this but it didn't work:

Me.YourTextbox = getLocations(Me.txPartN)

I also tried compact and repair.
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Does Me.txtPartN contain the value you expect? Put a breakpoint in the code, and use the Debug window to determine the value. If it does NOT contain the value you expect, then you'll have to determine why that is.

If it DOES contain the value, then the trouble lies in your GetLocations method, I would think, or else something else is overwriting the value. If you're using the Current method of the form, as I suggested, then be sure to REMOVE the call to the function in your event procedure declaration.
0
 
SteveL13Author Commented:
All I had to do was Office and Windows update.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.