Solved Function returning String not working (1 Viewer)

PatAccess

Registered User.
Local time
Today, 06:46
Joined
May 24, 2017
Messages
284
Hi Guys,
My function is not returning anything. what am I doing wrong here?
Code:
Private Sub Form_Load()
    Dim strSQLLst1 As String
'    strSQLLst1 = "SELECT LastOrdered,OrderNo,OrderedBy,SupplyCateg,VendorName,ItemNo,[Brand],[Color],[Size],MaxQt,MinQt "
'    strSQLLst1 = strSQLLst1 & "FROM QryTransactions ORDER BY LastOrdered"
    strSQLLst1 = SelectFromQryTransaction()
    Me.lstTransact1.RowSource = strSQLLst1
    Me.lstTransact1.Requery
End Sub

Private Function SelectFromQryTransaction() As String
    Dim strSQLLstRowSource As String
    strSQLLstRowSource = "SELECT LastOrdered,OrderNo,OrderedBy,SupplyCateg,VendorName,ItemNo,[Brand],[Color],[Size],MaxQt,MinQt "
    strSQLLstRowSource = strSQLLst1 & "FROM QryTransactions ORDER BY LastOrdered"
    SelectFromQryTransaction = strSQLLstRowSource
End Function
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:46
Joined
Sep 21, 2011
Messages
14,038
It should at least return just "from querytransactions ....."
You are mixing names in modules.

I see little point in doing this as well?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:46
Joined
Oct 29, 2018
Messages
21,357
Have you tried stepping through it? Try going to the Immediate Window and type this? What happens?
Code:
?SelectFromQryTransaction()
 

PatAccess

Registered User.
Local time
Today, 06:46
Joined
May 24, 2017
Messages
284
Have you tried stepping through it? Try going to the Immediate Window and type this? What happens?
Code:
?SelectFromQryTransaction()
I don't why I forgot about stepping through it. There was a mistake in my function and it caught it. Thank you so much
 

PatAccess

Registered User.
Local time
Today, 06:46
Joined
May 24, 2017
Messages
284
Have you tried stepping through it? Try going to the Immediate Window and type this? What happens?
Code:
?SelectFromQryTransaction()
The new code is now
Code:
Private Sub Form_Load()
    Dim strSQLLst1 As String
'    strSQLLst1 = "SELECT LastOrdered,OrderNo,OrderedBy,SupplyCateg,VendorName,ItemNo,[Brand],[Color],[Size],MaxQt,MinQt "
'    strSQLLst1 = strSQLLst1 & "FROM QryTransactions ORDER BY LastOrdered"
    strSQLLst1 = SelectFromQryTransaction()
    Me.lstTransact1.RowSource = strSQLLst1
    Me.lstTransact1.Requery
End Sub

Private Function SelectFromQryTransaction() As String
    Dim strSQLLstRowSource As String
    strSQLLstRowSource = "SELECT LastOrdered,OrderNo,OrderedBy,SupplyCateg,VendorName,ItemNo,[Brand],[Color],[Size],MaxQt,MinQt "
    strSQLLstRowSource = strSQLLstRowSource & "FROM QryTransactions ORDER BY LastOrdered"
    SelectFromQryTransaction = strSQLLstRowSource
End Function
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:46
Joined
Oct 29, 2018
Messages
21,357
I don't why I forgot about stepping through it. There was a mistake in my function and it caught it. Thank you so much
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Top Bottom