Chance1234
IS-IT--Management
I have a form which has three combo boxes and one option group on it. from there selections a Update SQL Query is created. it was working fine all until i had to add in the option group now ive lsot my mind.
for it to make more sense here is what the controls are
Combo103. Contains names of trading systems also there is an option all. in the table tblmain, each trading system has its own column and is boolean. (no they cant be consolidated into one column as they can be in more than one system)
Combo99. is just a list of Names of people
combo131 is a status selection which contains text such as Outstanding, Approved, Pending also it has an option all,
Finally frame131 has two options to overwrite records assigned or just those which arent.
bascily the front of the screen looks like this
All Records on System [combo103]
Assign them to [combo99]
Where status is [combo131]
Overright Assigned Records ? Y/N [frame131]
Where iam having trouble is with my brackets in the SQL through different combinations either one too many or one less
here is the code
Please please please help !!!!
Private Sub Command104_DblClick(Cancel As Integer)
Dim StrSql As String
Dim BolAnd As Boolean
StrSql = ""
StrSql = "UPDATE [(a)qryMaster] SET [tblmain].[Assigned To] = " & Combo99.Value & " "
If Combo103.Value = "ALL" Then
StrSql = StrSql
BolAnd = False
Else
StrSql = StrSql & " WHERE ((([tblmain].[" & Combo103.Value & "])=True)"
BolAnd = True
End If
If Combo131.Value = 999 Then
StrSql = StrSql
Else
If BolAnd = True Then
StrSql = StrSql & "AND ((tblMain.Status)=" & Combo131 & " "
Else
StrSql = StrSql & "WHERE ((tblMain.Status)=" & Combo131 & ""
End If
End If
If Frame133.Value = 1 Then
StrSql = StrSql & " "
Else
StrSql = StrSql & "AND (([tblmain].[Assigned To]) Is Null)));"
End If
docmd.execute SQL
End Sub
for it to make more sense here is what the controls are
Combo103. Contains names of trading systems also there is an option all. in the table tblmain, each trading system has its own column and is boolean. (no they cant be consolidated into one column as they can be in more than one system)
Combo99. is just a list of Names of people
combo131 is a status selection which contains text such as Outstanding, Approved, Pending also it has an option all,
Finally frame131 has two options to overwrite records assigned or just those which arent.
bascily the front of the screen looks like this
All Records on System [combo103]
Assign them to [combo99]
Where status is [combo131]
Overright Assigned Records ? Y/N [frame131]
Where iam having trouble is with my brackets in the SQL through different combinations either one too many or one less
here is the code
Please please please help !!!!
Private Sub Command104_DblClick(Cancel As Integer)
Dim StrSql As String
Dim BolAnd As Boolean
StrSql = ""
StrSql = "UPDATE [(a)qryMaster] SET [tblmain].[Assigned To] = " & Combo99.Value & " "
If Combo103.Value = "ALL" Then
StrSql = StrSql
BolAnd = False
Else
StrSql = StrSql & " WHERE ((([tblmain].[" & Combo103.Value & "])=True)"
BolAnd = True
End If
If Combo131.Value = 999 Then
StrSql = StrSql
Else
If BolAnd = True Then
StrSql = StrSql & "AND ((tblMain.Status)=" & Combo131 & " "
Else
StrSql = StrSql & "WHERE ((tblMain.Status)=" & Combo131 & ""
End If
End If
If Frame133.Value = 1 Then
StrSql = StrSql & " "
Else
StrSql = StrSql & "AND (([tblmain].[Assigned To]) Is Null)));"
End If
docmd.execute SQL
End Sub