R
ragtopcaddy via AccessMonster.com
I have the following code behind several after update events as well as form
current:
Function StoreCtls()
Dim blTorF As Boolean
Dim nBrand As Integer
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim strSelect As String
Dim strAnd As String
Dim strGroupBy As String
Dim strOrderBy As String
Dim rsATLOS As DAO.Recordset
Dim blATLOS As Boolean
Dim strPrftPct As String
Set qdf = dbLocal.QueryDefs("qryMktsCombo")
strSelect = "SELECT qryStoreMaster.[Market#], [Market Name], MktNm" & vbCrLf
strSelect = strSelect & "FROM qryStoreMaster" & vbCrLf
strSelect = strSelect & "WHERE Not qryStoreMaster.[Market#] Is Null"
strAnd = " AND Brand="
strGroupBy = vbCrLf & "GROUP BY qryStoreMaster.[Market#], [Market Name],
MktNm" & vbCrLf
strOrderBy = "ORDER BY qryStoreMaster.[Market#]"
With Me
blTorF = (Nz(.grpBrands, 0) = 0 And Nz(.grpPrftsOvrUnd, 0) = 0 And Nz(.
grpSlsOvrUnd, 0) = 0 _
And Nz(.cmbMarket, 0) = 0) And Nz(.grpProfit_, 0) = 0
.cmbStores.Visible = blTorF
.txtStoreBrand.Visible = blTorF
.txtStoreCityST.Visible = blTorF
.txtStoreDesc.Visible = blTorF
nBrand = .grpBrands
End With
Select Case nBrand
Case 0
strAnd = ""
Case 1
strAnd = strAnd & """ATS"""
Case 2
strAnd = strAnd & """ATF"""
Case 3
strAnd = strAnd & """ATL"""
Case 4
strAnd = strAnd & """ATLOS"""
End Select
With Me
.txtOver = 0
.txtUnder = 0
Select Case .grpProfit_
Case 0
.txtOver.Visible = False
.txtUnder.Visible = False
Case 1
.txtOver.Visible = True
.txtUnder.Visible = False
Case 2
.txtOver.Visible = False
.txtUnder.Visible = True
Case 3
.txtOver.Visible = True
.txtUnder.Visible = True
End Select
End With
qdf.SQL = strSelect & strAnd & strGroupBy & strOrderBy
'strSQL = "SELECT Brand FROM qryStoreMaster WHERE Not [Market#] Is Null AND
Sales>""0"" AND Profits>""0"" AND Brand=""ATLOS"""
strSQL = "SELECT BrandCode" & vbCrLf
strSQL = strSQL & "FROM (tblBrands INNER JOIN tblStoreMaster ON tblBrands.
BRANDID = tblStoreMaster.brandid)"
strSQL = strSQL & " INNER JOIN qryLTMSales ON tblStoreMaster.[Store #] =
qryLTMSales.[Store #]" & vbCrLf
strSQL = strSQL & "WHERE BrandCode=""ATLOS"" AND Not [Market#] Is Null AND
LTMSls>0"
Set rsATLOS = dbLocal.OpenRecordset(strSQL)
blATLOS = Not rsATLOS.EOF
With Me
With .cmbMarket
.RowSource = .RowSource
.Requery
End With
.optATLOS.Enabled = blATLOS
End With
rsATLOS.Close
Set rsATLOS = Nothing
End Function
Can anyone tell me why the form keeps recalculating? What workaround would
you suggest?
Thanks,
Bill
current:
Function StoreCtls()
Dim blTorF As Boolean
Dim nBrand As Integer
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim strSelect As String
Dim strAnd As String
Dim strGroupBy As String
Dim strOrderBy As String
Dim rsATLOS As DAO.Recordset
Dim blATLOS As Boolean
Dim strPrftPct As String
Set qdf = dbLocal.QueryDefs("qryMktsCombo")
strSelect = "SELECT qryStoreMaster.[Market#], [Market Name], MktNm" & vbCrLf
strSelect = strSelect & "FROM qryStoreMaster" & vbCrLf
strSelect = strSelect & "WHERE Not qryStoreMaster.[Market#] Is Null"
strAnd = " AND Brand="
strGroupBy = vbCrLf & "GROUP BY qryStoreMaster.[Market#], [Market Name],
MktNm" & vbCrLf
strOrderBy = "ORDER BY qryStoreMaster.[Market#]"
With Me
blTorF = (Nz(.grpBrands, 0) = 0 And Nz(.grpPrftsOvrUnd, 0) = 0 And Nz(.
grpSlsOvrUnd, 0) = 0 _
And Nz(.cmbMarket, 0) = 0) And Nz(.grpProfit_, 0) = 0
.cmbStores.Visible = blTorF
.txtStoreBrand.Visible = blTorF
.txtStoreCityST.Visible = blTorF
.txtStoreDesc.Visible = blTorF
nBrand = .grpBrands
End With
Select Case nBrand
Case 0
strAnd = ""
Case 1
strAnd = strAnd & """ATS"""
Case 2
strAnd = strAnd & """ATF"""
Case 3
strAnd = strAnd & """ATL"""
Case 4
strAnd = strAnd & """ATLOS"""
End Select
With Me
.txtOver = 0
.txtUnder = 0
Select Case .grpProfit_
Case 0
.txtOver.Visible = False
.txtUnder.Visible = False
Case 1
.txtOver.Visible = True
.txtUnder.Visible = False
Case 2
.txtOver.Visible = False
.txtUnder.Visible = True
Case 3
.txtOver.Visible = True
.txtUnder.Visible = True
End Select
End With
qdf.SQL = strSelect & strAnd & strGroupBy & strOrderBy
'strSQL = "SELECT Brand FROM qryStoreMaster WHERE Not [Market#] Is Null AND
Sales>""0"" AND Profits>""0"" AND Brand=""ATLOS"""
strSQL = "SELECT BrandCode" & vbCrLf
strSQL = strSQL & "FROM (tblBrands INNER JOIN tblStoreMaster ON tblBrands.
BRANDID = tblStoreMaster.brandid)"
strSQL = strSQL & " INNER JOIN qryLTMSales ON tblStoreMaster.[Store #] =
qryLTMSales.[Store #]" & vbCrLf
strSQL = strSQL & "WHERE BrandCode=""ATLOS"" AND Not [Market#] Is Null AND
LTMSls>0"
Set rsATLOS = dbLocal.OpenRecordset(strSQL)
blATLOS = Not rsATLOS.EOF
With Me
With .cmbMarket
.RowSource = .RowSource
.Requery
End With
.optATLOS.Enabled = blATLOS
End With
rsATLOS.Close
Set rsATLOS = Nothing
End Function
Can anyone tell me why the form keeps recalculating? What workaround would
you suggest?
Thanks,
Bill