To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

HOME News MS SQL Oracle DB2 Access MySQL PHP Scripts Books Links DBA Talk


Go Back   Database Journal Forums > Related Sites > SQL Course

SQL Course SQL Course > Ask questions about the lessons on SQL Course 1 and 2. If you have problems > with the interface, please post in the Feedback forum

Reply Post New Thread
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 01-22-2003, 03:11 PM
W Sasser W Sasser is offline
Junior Member
 
Join Date: Jan 2003
Posts: 1
Using Combo Boxes to input into SQL for updating a table

HELP

I am trying to use variables from combo boxes to update a table. I want the users to be able to select specific data to update a table (namely a single field in the table, and it is boolean)

The code I've written is as such:

Private Sub cmdCalculate_Click()

Dim strShift As String
Dim strYear As String
Dim strMonth As String
Dim strGoal As String
'Dim rsEmpTotal As Recordset
Dim cmdUpdate As ADODB.Command
Dim strSQL As String

Set cmdUpdate = New ADODB.Command
'Set rsEmpTotal = New ADODB.Recordset

strShift = Me.cboShift

intMonth = Me.cboMonth
intYear = Me.cboYear
strGoal = Me.cboGoal

'rsEmpTotal.Open

strSQL = "Update tblEmpTotals SET Achieve = True Where Goal_N = 'strGoal' and Month = 'strMonth' and Year = 'strYear' and Shift = 'strShift'"
'strSQL = "Update tblEmpTotals SET Achieve = True Where Goal_N = 'PPIM'"

Debug.Print strSQL

With cmdUpdate
.ActiveConnection = CurrentProject.Connection
.CommandText = strSQL
.CommandType = adCmdText
.Execute
End With

End Sub


The areas I've added the apostrophe, is tried and true. When I debug, the code is NOT transferring from the variables to the strSQL string. I did use the strSQL string in the CommandText first. That didn't work so I moved it outside the variable and it still didn't take it.

In the strSQL I've done it with quotes, without quotes.

HELP
Reply With Quote
  #2  
Old 01-30-2003, 09:40 AM
JBane JBane is offline
Registered User
 
Join Date: Dec 2002
Posts: 181
WSasser,

strSQL = "Update tblEmpTotals SET Achieve = True Where Goal_N = 'strGoal' and Month = 'strMonth' and Year = 'strYear' and Shift = 'strShift'"

should be:


strSQL = "Update tblEmpTotals SET Achieve = True Where Goal_N = '" & strGoal & "' and Month = '" & strMonth & "' and Year = '" & strYear & "' and Shift = '" & strShift & "'"

Jeff
Reply With Quote
Reply Post New Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:56 AM.


DatabaseJournal Recent Articles


 » Preparing To Upgrade Access Tables to SQL ...

 » Microsoft Windows PowerShell and SQL Serve...

 » New MySQL Enterprise with Query Analyzer B...

 » Quest Software Strengthens Committment to ...

 » Oracle Unveils New Event-Driven Middleware...

Search Database Journal:
 





Acceptable Use Policy

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.