Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 21st, 2009, 02:08 PM
sepehr sepehr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 9 sepehr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 6 sec
Reputation Power: 0
Question Reports - Change data in a tabel

hello

how can i change a row's data from a form that have no relationships with that table?

thanks

Reply With Quote
  #2  
Old October 21st, 2009, 06:31 PM
don94403's Avatar
don94403 don94403 is offline
Contributing User
Click here for more information.
 
Join Date: Jan 2007
Location: Northern California
Posts: 2,886 don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level)don94403 User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Weeks 1 Day 1 h 18 m 41 sec
Reputation Power: 562
Quote:
Originally Posted by sepehr
hello

how can i change a row's data from a form that have no relationships with that table?

thanks
By writing an event procedure in VBA that updates the table.
__________________
Experience is the thing you have left when everything else is gone.

Reply With Quote
  #3  
Old October 22nd, 2009, 05:30 AM
sepehr sepehr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 9 sepehr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 6 sec
Reputation Power: 0
Question

and what's that event procedure?

Reply With Quote
  #4  
Old October 22nd, 2009, 01:14 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
Use a button Click or form Close or box Update event with code like:

DoCmd.RunSQL "UPDATE tablename SET fieldname ='" & name of variable or box here & "' WHERE fieldname = '" & some value here probably from a variable or box or recordset field & "'"

The apostrophes are needed if field is text, # symbol if field is date and nothing if field is numeric. Note how the variables are concatenated, if you use literals don't concatenate, just include within the quotes but delimiter rules still apply.

Attempt code, post for analysis if you encounter problem.

Last edited by June7 : October 22nd, 2009 at 01:20 PM.

Reply With Quote
  #5  
Old October 22nd, 2009, 01:50 PM
sepehr sepehr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 9 sepehr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 6 sec
Reputation Power: 0
...
i am a bit new to access and i dont know SQL...

by the way i don't undrestand this thing that you wrote in code:
"some value here probably from a variable or box or recordset field"

...



i want to change data on the "customers" tabel at the field "index"

to a certain row that is on "rowcode" variable ,it's a number

and insert "f$" to it.

can you change the code to this mode?

....

DoCmd.RunSQL "UPDATE customers SET customers.index ='" & F$ & "' WHERE customers.index= '" & i dont know what to insert & "'"

Last edited by sepehr : October 22nd, 2009 at 01:53 PM. Reason: wrong word

Reply With Quote
  #6  
Old October 22nd, 2009, 03:24 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
If you don't give the SQL command criteria in the WHERE clause, every record will be updated. So you need to 'capture' the criteria somehow. Possibly by reference to fields of the record the form is open to or by having user enter value into a textbox or determined somehow in code.

Tell me more about this 'index' field. What is it for? The example you show would find every record with a particular index value and replace that value. You mention a variable 'rowcode'. How is its value set? Would it be a value in a field in the table?

Suggest you look at some SQL tutorials. There are lots available on the net. Here's one for starters http://www.sql-tutorial.net/

Last edited by June7 : October 23rd, 2009 at 01:04 PM.

Reply With Quote
  #7  
Old October 23rd, 2009, 05:42 AM
sepehr sepehr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 9 sepehr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 6 sec
Reputation Power: 0
Question ?



....

so my code will be:

for rowcode = 0 to txtnumber - 1

f$ = SOME CALCULATIONS

DoCmd.RunSQL "UPDATE customers SET customers.index ='" & F$ & "' WHERE customers.ID= '" & rowcode + 1 & "'"

next rowcode

...

but "Data type mismatch in criteria expression." Error will appear.

the thing in f$ will be a 3 digit number but like as this :"018"

i dont want to be converted to 18 instead of "018"...

Reply With Quote
  #8  
Old October 23rd, 2009, 06:10 AM
sepehr sepehr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 9 sepehr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 6 sec
Reputation Power: 0
Question ?



just converted "rowcode" to a string and it works:

DoCmd.RunSQL "UPDATE customers SET customers.index ='" & F$ & "' WHERE customers.ID= '" & mid$(rowcode + 1,1) & "'"

...



...

can i disable that confirmation?, because my operation will not effect any user's data, it's just sending (and saving) information to another form

Reply With Quote
  #9  
Old October 23rd, 2009, 01:03 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
Code:
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE customers SET customers.index ='" & F$ & "' WHERE customers.ID= '" & mid$(rowcode + 1,1) & "'"
DoCmd.SetWarnings True
What do you mean by
Quote:
because my operation will not effect any user's data, it's just sending (and saving) information to another form
This UPDATE statement IS changing data, not sending info to another form.

Reply With Quote
  #10  
Old October 24th, 2009, 12:21 PM
sepehr sepehr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 9 sepehr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 6 sec
Reputation Power: 0
Smile thanks

thanks a lot for your help,
Quote:
What do you mean by
Quote:
because my operation will not effect any user's data, it's just sending (and saving) information to another form

This UPDATE statement IS changing data, not sending info to another form.

I'm just using it to save that data to be read by another form, its one of the user settings.

Reply With Quote
  #11  
Old October 24th, 2009, 03:12 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
That is one way to make the value available but it isn't necessary to save a value to a table in order to pass to another form. If you have no other purpose for the value you can use the OpenArgs argument of the DoCmd.OpenForm command if the form is to be opened by the form that captures the value. If you need the value later then could use a global variable.
Comments on this post
sepehr disagrees!

Reply With Quote
  #12  
Old October 30th, 2009, 07:13 PM
June7 June7 is offline
Contributing User
Click here for more information.
 
Join Date: Apr 2009
Location: The Great Land
Posts: 536 June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level)June7 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 13 h 58 m 7 sec
Reputation Power: 124
sepehr,
What point do you disagree with? Perhaps I could clarify.

I routinely pass values to a form or report without saving to a table. I am not saying that is the best approach for your situation but it is an option.

Reply With Quote
  #13  
Old November 4th, 2009, 11:28 AM
sepehr sepehr is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 9 sepehr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 6 sec
Reputation Power: 0


oh sorry ,i was exploring site places ,just wanted to see what will happen...

.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Reports - Change data in a tabel


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek