Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Query not updating variable

$
0
0
I am using the afterUpdate event on a list box to do a query and set a variable to the value from a table. The first two queries function as expected but the third one does not and yet is the same as the first two. I am looking for an explanation as to why not and a suggestion to fix or another approach. The underlying tables are the same construction differing only in the third table having two yes/no fields, I don't think that is an issue. I suspect it revolves around the recordset and snapshot. Thanks in advance, code follows
_______________________________________________


Private Sub lbFilter_AfterUpdate()
Dim Choice2
Dim DB As Database
Dim rst As Recordset
Dim rst2 As Recordset
Dim rst33 As Recordset
Dim THisSQL As String
Dim THisSQL2 As String
Dim THisSQL33 As String

''' act on the choice of contracts by COR
''' run a new query based on lbFilter value and use the ID number to pull all associated records from data values table. Then use the contract number to open the record

Choice2 = Me.lbFilter.Value
Label21.Visible = False

THisSQL = "SELECT [COR].[ID], [COR].[Location] FROM COR"
Set rst = CurrentDb.OpenRecordset(THisSQL, dbOpenSnapshot)
COR_ID = rst![ID] ' works - sets value to pass to update event

THisSQL2 = "SELECT [Contract_Groups].[Number] FROM Contract_Groups"
Set rst2 = CurrentDb.OpenRecordset(THisSQL2, dbOpenSnapshot)
Group_Number = rst2![Number] ' works - sets value to pass to update event

‘’’’’ The following three lines are the problem, the recordset is stuck on record one and not changing to the selected value in the listbox (lbFilter)
THisSQL33 = "SELECT [Station_Lookup].[Number] FROM Station_Lookup"
Set rst33 = CurrentDb.OpenRecordset(THisSQL33, dbOpenSnapshot)
StnName = rst33![Number] ' does not work

Call ListChoice3(Choice2, OneofFourChoice, COR_ID, Group_Number, StnName)

Viewing all articles
Browse latest Browse all 13329

Trending Articles