Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please can someone check my code 1

Status
Not open for further replies.

Chance1234

IS-IT--Management
Jul 25, 2001
7,871
US
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
 
Thanks annyway but u need to be shure there is no error in your code or statments cuz finally may cause problems and u need to reconsider the code again...dont worth it...
If u need help in vb coding or some like that please tell us maybe we help... ________

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top