Change an Insert query into an Update query (1 Viewer)

violentjay25

Registered User.
Local time
Today, 03:24
Joined
Feb 22, 2005
Messages
30
The Add query works perfect. I would like to duplicate this query and change it to an Update query but I can not get it to work. Can anyone please HELP!!!
I have an update query that works fine but access will not allow me to update any characters over 1024.

Private Sub cmdAdd_Click()
DoCmd.RunSQL "Insert into tbl_Projects (ProjectName, SystemsImpacted, SPRNum,ReleaseDate, Status, CSIPM, BPM, Implemented, StakeHolder, IBR1, IBR2, IBR3, Objective, SMERequirments, Phase) " & _
"Values ('" & Me.txtProjectName & "', '" & _
Me.TxtSystemsImpacted & "', '" & _
Me.txtSPR & "', '" & _
Me.txtReleaseDate & "', '" & _
Me.CboStatus & "', '" & _
Me.txtCSI & "', '" & _
Me.txtBPM & "', '" & _
Me.cboImplemented & "', '" & _
Me.cboStakeholder & "', '" & _
Me.cboIBR1 & "', '" & _
Me.cboIBR2 & "', '" & _
Me.cboIBR3 & "', '" & _
Me.txtObjective & "', '" & _
Me.txtSMERequirements & "', '" & _
Me.cboPhase & "')"

End Sub
 

Crilen007

Uhm, Title... *shrug*
Local time
Today, 01:24
Joined
Jun 13, 2003
Messages
531
make an update query in access then view the SQL script to see how its made. THen see how you can create the one you want.
 

violentjay25

Registered User.
Local time
Today, 03:24
Joined
Feb 22, 2005
Messages
30
That did not work This code does BUT!!!

This code works fine. The problem is when I try to update anything over 1024 charachers access give me this

Run-time Error '2246
Access cant runt he query, the parameter values are too large
The total length of all the values entered for the parameters cannot exceed 1,024 characthers.

So what I want to do is modify the code I listed before to do an update and not an insert. The reason I want to do that is because that query will allow me to insert more that 1024 charachters

DoCmd.RunSQL "UPDATE tbl_Projects SET " & _
"tbl_Projects.SPRNum = [Forms]![frmEdit]![txtSPR], " & _
"tbl_Projects.SystemsImpacted = [Forms]![frmEdit]![txtSystemsImpacted], " & _
"tbl_Projects.ReleaseDate = [Forms]![frmEdit]![txtReleaseDate], " & _
"tbl_Projects.Status = [Forms]![frmEdit]![cboStatus], " & _
"tbl_Projects.CSIPM = [Forms]![frmEdit]![txtCSI], " & _
"tbl_Projects.BPM = [Forms]![frmEdit]![txtBPM], " & _
"tbl_Projects.Implemented = [Forms]![frmEdit]![cboImplemented], " & _
"tbl_Projects.StakeHolder = [Forms]![frmEdit]![cboStakeholder], " & _
"tbl_Projects.IBR1 = [Forms]![frmEdit]![cboIBR1], " & _
"tbl_Projects.IBR2 = [Forms]![frmEdit]![cboIBR2], " & _
"tbl_Projects.IBR3 = [Forms]![frmEdit]![cboIBR3], " & _
"tbl_Projects.Objective = [Forms]![frmEdit].[txtObjective] , " & _
"tbl_Projects.SMERequirments = [Forms]![frmEdit].[txtSMERequirements] , " & _
"tbl_Projects.Phase = [Forms]![frmEdit]![cboPhase] " & _
"WHERE tbl_Projects.ProjectName =[Forms]![frmEdit]![cboProjectName]; "
 

Crilen007

Uhm, Title... *shrug*
Local time
Today, 01:24
Joined
Jun 13, 2003
Messages
531
hmm, usually that error comes when you miss a


"


somewhere.

Verify your code works by just having it go into a text box. (the final code, that is).


IE:

Make a large text box and call it txtcodecheck

then have the button or whatever do this:

Code:
dim sqlstring as string

sqlstring = "UPDATE tbl_Projects SET " & _
"tbl_Projects.SPRNum = [Forms]![frmEdit]![txtSPR], " & _
"tbl_Projects.SystemsImpacted = [Forms]![frmEdit]![txtSystemsImpacted], " & _
"tbl_Projects.ReleaseDate = [Forms]![frmEdit]![txtReleaseDate], " & _
"tbl_Projects.Status = [Forms]![frmEdit]![cboStatus], " & _
"tbl_Projects.CSIPM = [Forms]![frmEdit]![txtCSI], " & _
"tbl_Projects.BPM = [Forms]![frmEdit]![txtBPM], " & _
"tbl_Projects.Implemented = [Forms]![frmEdit]![cboImplemented], " & _
"tbl_Projects.StakeHolder = [Forms]![frmEdit]![cboStakeholder], " & _
"tbl_Projects.IBR1 = [Forms]![frmEdit]![cboIBR1], " & _
"tbl_Projects.IBR2 = [Forms]![frmEdit]![cboIBR2], " & _
"tbl_Projects.IBR3 = [Forms]![frmEdit]![cboIBR3], " & _
"tbl_Projects.Objective = [Forms]![frmEdit].[txtObjective] , " & _
"tbl_Projects.SMERequirments = [Forms]![frmEdit].[txtSMERequirements] , " & _
"tbl_Projects.Phase = [Forms]![frmEdit]![cboPhase] " & _
"WHERE tbl_Projects.ProjectName =[Forms]![frmEdit]![cboProjectName]; "


txtcodecheck = sqlstring

Then verify that it looks correct.
 

violentjay25

Registered User.
Local time
Today, 03:24
Joined
Feb 22, 2005
Messages
30
This code works

This code works if I dont put too many char's in the text box. When I start writing a novel then it gives me that error. What I am trying to do is "Update Values". The insert code works and I can put as many chars' as I want. I need to know how to modify it to update
 

Crilen007

Uhm, Title... *shrug*
Local time
Today, 01:24
Joined
Jun 13, 2003
Messages
531
Why are you writing a novel and then using an update query?


Why not just add it directly to the form?
 

Crilen007

Uhm, Title... *shrug*
Local time
Today, 01:24
Joined
Jun 13, 2003
Messages
531
Anyways, At this point im not sure.

I've never had a problem with fields being too large, and I assume that you have your reason for not editing the record directly.

However, there are limits to things, and having a giant update query that has a novel in it, is one of them, i suppose.
 

violentjay25

Registered User.
Local time
Today, 03:24
Joined
Feb 22, 2005
Messages
30
My insert query works

The insert query works just fine. I can add as much data as I want. All this data is housed on a SQL server so space is not an issue. This database houses projects and what is going on with them. The user need to be able to talk to what is going on with the project. They are able to do this with the insert query but if they made a mistake and need to change it...the update query does not work
 

Users who are viewing this thread

Top Bottom