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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
SteveL13Author Commented:
I tried this but it didn't work:

Me.YourTextbox = getLocations(Me.txPartN)

I also tried compact and repair.
0
Acronis Data Cloud 7.8 Enhances Cyber Protection

A closer look at five essential enhancements that benefit end-users and help MSPs take their cloud data protection business further.

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:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveL13Author Commented:
All I had to do was Office and Windows update.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.