473,769 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update query

Help, i want to run an update query from a form..
and was wonderin..

Can the update query run if i want to update a value manually inputted
from a form (e.g. [Forms]![frmUpdatePW]![txtConfirmPW]) to a table
(tblPasswordMgm t.Password)

but based on a criteria which is neither the two values. Instead it's
like ([Forms]![frmUpdatePW]![txtusername]=tblPasswordMgm t.UserID).

in a nutshell,

UPDATE tblPasswordMgmt
SET (Qn : The command SET is it SET TO or SET FROM?)
WHERE (Qn : Can the command WHERE be specified which has no relevance
to the value that i want to update?)

Can the query "plucked out" the value from the form to update
exclusively to a specific field in the table? and this specific field
must match another value input by the user which matches to another
field in the table before updating the field in the table.

Thanxs Lotsa!

Jan 21 '06 #1
15 3309
On 21 Jan 2006 06:06:02 -0800, "Darren" <Ye********@gma il.com> wrote:
Help, i want to run an update query from a form..
and was wonderin..

Can the update query run if i want to update a value manually inputted
from a form (e.g. [Forms]![frmUpdatePW]![txtConfirmPW]) to a table
(tblPasswordMg mt.Password)

but based on a criteria which is neither the two values. Instead it's
like ([Forms]![frmUpdatePW]![txtusername]=tblPasswordMgm t.UserID).

in a nutshell,

UPDATE tblPasswordMgmt
SET (Qn : The command SET is it SET TO or SET FROM?)
WHERE (Qn : Can the command WHERE be specified which has no relevance
to the value that i want to update?)

Can the query "plucked out" the value from the form to update
exclusively to a specific field in the table? and this specific field
must match another value input by the user which matches to another
field in the table before updating the field in the table.

Thanxs Lotsa!

If the values are strings you need to wrap the control refrerences in quotes. (I use Chr(34)

strSQL ="UPDATE tblPasswordMgmt " _
& "SET [SomeField]=" & Chr(34) & Me.[txtConfirmPW].Value & Chr(34) & " " _
& "WHERE [UserID]=" & Chr(34) & Me.txtusername & Chr(34) & ";"

CurrentDB.Execu te strSQL, dbFailOnError
Wayne Gillespie
Gosford NSW Australia
Jan 21 '06 #2
On Sat, 21 Jan 2006 15:48:32 GMT, Wayne Gillespie <be*****@NOhotm ailSPAM.com.au> wrote:
On 21 Jan 2006 06:06:02 -0800, "Darren" <Ye********@gma il.com> wrote:
Help, i want to run an update query from a form..
and was wonderin..

Can the update query run if i want to update a value manually inputted
from a form (e.g. [Forms]![frmUpdatePW]![txtConfirmPW]) to a table
(tblPasswordM gmt.Password)

but based on a criteria which is neither the two values. Instead it's
like ([Forms]![frmUpdatePW]![txtusername]=tblPasswordMgm t.UserID).

in a nutshell,

UPDATE tblPasswordMgmt
SET (Qn : The command SET is it SET TO or SET FROM?)
WHERE (Qn : Can the command WHERE be specified which has no relevance
to the value that i want to update?)

Can the query "plucked out" the value from the form to update
exclusively to a specific field in the table? and this specific field
must match another value input by the user which matches to another
field in the table before updating the field in the table.

Thanxs Lotsa!

If the values are strings you need to wrap the control refrerences in quotes. (I use Chr(34)

strSQL ="UPDATE tblPasswordMgmt " _
& "SET [SomeField]=" & Chr(34) & Me.[txtConfirmPW].Value & Chr(34) & " " _
& "WHERE [UserID]=" & Chr(34) & Me.txtusername & Chr(34) & ";"

CurrentDB.Exec ute strSQL, dbFailOnError
Wayne Gillespie
Gosford NSW Australia


Should be

strSQL ="UPDATE tblPasswordMgmt " _
& "SET [Password]=" & Chr(34) & Me.[txtConfirmPW].Value & Chr(34) & " " _
& "WHERE [UserID]=" & Chr(34) & Me.txtusername & Chr(34) & ";"

CurrentDB.Execu te strSQL, dbFailOnError
Wayne Gillespie
Gosford NSW Australia
Jan 22 '06 #3
Hi, should it be in a module or can it be in a macro, with runSQL code:
strSQL ="UPDATE tblPasswordMgmt " _
& "SET [SomeField]=" & Chr(34) & Me.[txtConfirmPW].Value & Chr(34)
& " " _
& "WHERE [UserID]=" & Chr(34) & Me.txtusername & Chr(34) & ";"
And if i were to place it in a query, it prompts for an invalid SQL
expression

Jan 24 '06 #4
On 23 Jan 2006 22:24:14 -0800, "Darren" <Ye********@gma il.com> wrote:
Hi, should it be in a module or can it be in a macro, with runSQL code:
strSQL ="UPDATE tblPasswordMgmt " _
& "SET [SomeField]=" & Chr(34) & Me.[txtConfirmPW].Value & Chr(34)
& " " _
& "WHERE [UserID]=" & Chr(34) & Me.txtusername & Chr(34) & ";"
And if i were to place it in a query, it prompts for an invalid SQL
expression


If you are running this from a form, I would put the code in the Form's module.

eg If you want to run the update from a command button, The code would be pasted into the Click event of the command
button.

To test it, add a command button to a form (btnUpdate).
In design view click on the command button and in the properties sheet select the OnClick event. Type [Event Procedure]
and click the (...) button at the right of the property. The form's code module will open up with the procedure header
and footer filled in.

Post the code between the header and footer so it looks like -

Sub btnUpdate_Click ()
Dim strSQL as String

strSQL ="UPDATE tblPasswordMgmt " _
& "SET [Password]=" & Chr(34) & Me.[txtConfirmPW].Value & Chr(34) & " " _
& "WHERE [UserID]=" & Chr(34) & Me.txtusername & Chr(34) & ";"

CurrentDB.Execu te strSQL, dbFailOnError

End Sub

When the button is clicked, the code will execute.
Wayne Gillespie
Gosford NSW Australia
Jan 24 '06 #5
Hi, now that i could run this macro...
i haf another problem..becoz i have 3 different level of permissions
for 3 different groups of users, therefore their passwords are found in
3 separate tables. Therefore, i want to update the password but it must
find it in the correct table to update.

How can i do that?

Thanks for that..realli sorry for da trouble!

Jan 24 '06 #6
and if i were to have a macro run before this code, how should i go
about doing dis?

thanxs! You have been a very great help!

Jan 24 '06 #7
Say it looks like this..

Private Sub cmdconfirm_Clic k()
On Error GoTo Err_cmdconfirm_ Click

IF Me.[txtusername] = Dlookup("UserID ,"tblPasswordMg mt")

THEN
Dim strSQL As String

strSQL = "UPDATE tblPasswordMgmt " _
& "SET [Password]=" & Chr(34) & Me.[txtConfirmPW].Value & Chr(34)
& " " _
& "WHERE [UserID]=" & Chr(34) & Me.txtusername & Chr(34) & ";"
CurrentDb.Execu te strSQL, dbFailOnError

END IF

IF Me.[txtusername] = Dlookup("UserID ,"tblPasswordPu rchase")

THEN
Dim strSQL As String

strSQL = "UPDATE tblPasswordPurc hase " _
& "SET [Password]=" & Chr(34) & Me.[txtConfirmPW].Value & Chr(34)
& " " _
& "WHERE [UserID]=" & Chr(34) & Me.txtusername & Chr(34) & ";"
CurrentDb.Execu te strSQL, dbFailOnError

END IF

IF Me.[txtusername] = Dlookup("UserID ,"tblPasswordRe ceivi")

THEN
Dim strSQL As String

strSQL = "UPDATE tblPasswordRece ivi " _
& "SET [Password]=" & Chr(34) & Me.[txtConfirmPW].Value & Chr(34)
& " " _
& "WHERE [UserID]=" & Chr(34) & Me.txtusername & Chr(34) & ";"
CurrentDb.Execu te strSQL, dbFailOnError

END IF
Exit_cmdconfirm _Click:
Exit Sub

Err_cmdconfirm_ Click:
MsgBox Err.Description
Resume Exit_cmdconfirm _Click

End Sub

Will it work if i put the 3 conditions?

Jan 24 '06 #8
On 24 Jan 2006 00:03:24 -0800, "Darren" <Ye********@gma il.com> wrote:
and if i were to have a macro run before this code, how should i go
about doing dis?

thanxs! You have been a very great help!


I never use macros but I think you can add a line in the same procedure like -

DoCmd.RunMacro "MacroName"
Wayne Gillespie
Gosford NSW Australia
Jan 24 '06 #9
On 23 Jan 2006 23:56:31 -0800, "Darren" <Ye********@gma il.com> wrote:
Hi, now that i could run this macro...
i haf another problem..becoz i have 3 different level of permissions
for 3 different groups of users, therefore their passwords are found in
3 separate tables. Therefore, i want to update the password but it must
find it in the correct table to update.

How can i do that?

Thanks for that..realli sorry for da trouble!


It sounds to me like you have a design problem with your basic data structure.
I would suggest that you redesign your table so that all passwords are in the one table. There should be no reason to
have separate tables for each permission level. Combine them into a single table and include fields in the table to
indicate the permission level.
Wayne Gillespie
Gosford NSW Australia
Jan 24 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10237
by: Surendra | last post by:
I have this query that I need to use in an Update statement to populate a field in the table by the value of Sq ---------------------------------------------------------------------------- Inline View Query: Select Sq from ( Select substr(to_date(End_Date,"DD-MON-YYYY"),4), End_Date, Rank() Over (Partition by substr(to_date(End_Date,"DD-MON-YYYY"),4) Order by End_Date) As Sq
2
8541
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An example of what I'm trying to do is below: update (tbl_ind_mananas LEFT JOIN (select count(*) as count, (dubicacion || zona || manzana) as cod_manzana from tbl_censo_poblacion_1993 group by dubicacion, zona, manzana) tbl1 on relacion = cod_manzana) as...
10
3280
by: Randy Harris | last post by:
I imported records into a table, later found out that many of them had trailing spaces in one of the fields. If I'd caught it sooner, I could have trimmed the spaces before the import. This wouldn't work (nothing changed): UPDATE tblManuals SET tblManuals.PARTNUM = Trim(); Would someone please tell me how to do an update query that will trim the spaces?
4
11340
by: deko | last post by:
I'm trying to update the address record of an existing record in my mdb with values from another existing record in the same table. In pseudo code it might look like this: UPDATE tblAddress SET AddressDescription of Entity 456 = AddressDescription of Entity_ID 123 Address1 of Entity 456 = Address1 of Entity_ID 123 City of Entity 456 = City of Entity_ID 123
8
3724
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: "Date","P1","P2","P3","P4","P5","P6","P7","P8","P9","P10","P11","P12","P13","P14","P15","P16","P17","P18","P19","P20","P21" 1/1/2005,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 1/2/2005,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
7
3538
by: Mark Carlyle via AccessMonster.com | last post by:
I have this update query that I am trying to run. I know the syntax is messed up but do not know how to correct it. Select 'UPDATE', Transactions,'Set = where = ' From "Get Daily Balances" Transactions = name of the table I want to update balance = name of the field i want to update daily balance= name of the query result that I want to move to the table
3
3451
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all the necessary records in it when testing it. I get the error "No value given for one or more required parameters." when I try to update the database. Can you tell me what am I doing wrong?
31
2450
by: Lag | last post by:
Having a problem updating my database from a web page, through a submission form. Can anyone help? ----THIS IS MY CODE IN update.php----(user, pass, and database are typed in directly, I changed them here for securiy reasons :) ) <?php /*---CONNECT TO DATABASE---*/
3
2682
by: eholz1 | last post by:
Hello PHP programmers. I had a brilliant idea on one of my pages that selects some data from my mysql database. I first set the page up to display some info and an image, just one item, with a row of data, etc. then I thought it would be nice to do a select, and perhaps an update (the title of the image) on the same page.
16
3519
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate (tried a groups query, but "count" won't work), then do an update query to change the duplicate to...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.