E
ellidavd
I have a form with three textboxes:
txtAisle
txtSect
txtBox
I have a table called Hoods with columns that correspond to those three
textboxes:
Hoods.Aisle
Hoods.Sect
Hoods.Box
I would like to run a query to get the maximum value from the Hoods.Box
column based on the input from txtAisle and txtSect and put that value
into txtBox.
I have done this before using VB.Net and C#, but for some reason I am
not able to get it in Access.
I know how to run the query in code. The following code works:
Private Sub btnBox_Click()
Dim strSQL As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim AisleHold As String
Dim SectHold As String
Set db = CurrentDb
strSQL = "SELECT Max([Hoods].[Box]) AS [Max Of Box]FROM Hoods WHERE
Aisle=" & txtAisle & "And Sect=" & txtSect & ";"
db.QueryDefs.Delete "qryMyQuery"
Set qdf = db.CreateQueryDef("qryMyQuery", strSQL)
DoCmd.OpenQuery "qryMyQuery", acNormal, acEdit
End Sub
I would like to place the result of the query in a variable to display
in txtBox rather than having a datasheet appear with the result.
Thanks for any help.
txtAisle
txtSect
txtBox
I have a table called Hoods with columns that correspond to those three
textboxes:
Hoods.Aisle
Hoods.Sect
Hoods.Box
I would like to run a query to get the maximum value from the Hoods.Box
column based on the input from txtAisle and txtSect and put that value
into txtBox.
I have done this before using VB.Net and C#, but for some reason I am
not able to get it in Access.
I know how to run the query in code. The following code works:
Private Sub btnBox_Click()
Dim strSQL As String
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim AisleHold As String
Dim SectHold As String
Set db = CurrentDb
strSQL = "SELECT Max([Hoods].[Box]) AS [Max Of Box]FROM Hoods WHERE
Aisle=" & txtAisle & "And Sect=" & txtSect & ";"
db.QueryDefs.Delete "qryMyQuery"
Set qdf = db.CreateQueryDef("qryMyQuery", strSQL)
DoCmd.OpenQuery "qryMyQuery", acNormal, acEdit
End Sub
I would like to place the result of the query in a variable to display
in txtBox rather than having a datasheet appear with the result.
Thanks for any help.