Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Business Applications
Tag Cloud
access acer asus batch bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard mouse network printer problem ram registry router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Access edit data of currently open record in a form

Reply  
Thread Tools
Gudzy's Avatar
Member with 43 posts.
 
Join Date: Jan 2009
Experience: Beginner
12-Feb-2009, 12:56 PM #1
Solved: Access edit data of currently open record in a form
I've made a button on a form which, when pressed, adds 1 to one field and adds 7 to another.

The problem I am having is selecting which record this applies to.

I am wanting for the button to apply to the record on display in the form.

I've been able to get the number of the current record into a variable lngrecordnum but am unsure how I can use this to select the record I want to edit

Any help is much appreciated. My code is below:

Sub CallMade()
Dim dbs As DAO.Database
Dim rstQuotes As DAO.Recordset
Dim lngrecordnum As Long
Set dbs = CurrentDb
Set rstCustomerQuotes = dbs.OpenRecordset("Quotes Table")

lngrecordnum = Forms![Quotes Table Form].CurrentRecord

'Select which record here

rstQuotes.Edit
rstQuotes!Call_attempt = rstQuotes!Call_attempt + 1
rstQuotes!Priority = rstQuotes!Priority + 7
rstQuotes.Update
End Sub
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 14,665 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
12-Feb-2009, 01:24 PM #2
If you are working with the Current Record on the Current Form you do not need a recordset, you can work directly with the Fields on the Form.
If you want to use a Recordset use a RecordsetClone and Bookmark the Recordset to the Form bookmark.
if RS is the recordsetclone you would use
rs.bookmark = me.bookmark.

Of Course this assumes that you are Using a BOUND Form.
__________________
OBP
I do not give up easily
Gudzy's Avatar
Member with 43 posts.
 
Join Date: Jan 2009
Experience: Beginner
12-Feb-2009, 01:28 PM #3
Quote:
Originally Posted by OBP View Post
If you are working with the Current Record on the Current Form you do not need a recordset, you can work directly with the Fields on the Form.
If you want to use a Recordset use a RecordsetClone and Bookmark the Recordset to the Form bookmark.
if RS is the recordsetclone you would use
rs.bookmark = me.bookmark.

Of Course this assumes that you are Using a BOUND Form.
Thanks for the quick reply

I'm just working on the current record on the current form.

How do I work directly with the fields on the form, can I just put Priority = Priority + 7 for example?
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 14,665 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
12-Feb-2009, 01:42 PM #4
me.priority = me.priority + 7
rbalaji's Avatar
Computer Specs
Member with 328 posts.
 
Join Date: Feb 2009
Location: Chicagoland
Experience: Intermediate
12-Feb-2009, 04:14 PM #5
This will work assuming the form is bound to the table or simple updateable query (not through a non-updateable query) and the fields in question are bound fields. Otherwise, you can use VBA to run an update query with the necessary updates. All records in an access database should have a primary key that you should use to identify them for any reason. Access provides a simple mechanism for this with the autonumber type which you can use with any table to create a simple primary key. You should use this primary key field in the update query to identify the record to update.
__________________
Balaji Ramanathan
-----------------------------------------
Fail-safe systems do
Operating systems don't
-----------------------------------------
Gudzy's Avatar
Member with 43 posts.
 
Join Date: Jan 2009
Experience: Beginner
13-Feb-2009, 06:08 AM #6
Thanks, that works as it should.

The primary key is a unique quote reference, which is used in a bespoke database.

As for the bound form stuff, I don't really know what you mean.

I am importing emails form outlook using a linked table (Customer Quotes), then appending that data into a table (Customer Quotes Table) so I can extract some of the information into new fields, such as name, reference etc.

The form (Customer Quotes Table Form) is then just an easier way for the users to the view the information and to provide the automated buttons (the button I've asked about increments the calls_made field is by 1 and priority by 7)

I've started a new thread regarding an automated email problem here: http://forums.techguy.org/business-a...ml#post6494818

Last edited by Gudzy; 13-Feb-2009 at 06:16 AM..
OBP's Avatar
OBP OBP is offline
Computer Specs
Distinguished Member with 14,665 posts.
 
Join Date: Mar 2005
Location: UK
Experience: An old Basic Programmer
13-Feb-2009, 07:16 AM #7
Gudzy, a "Bound" form just means that it has the normal Record Source of a Table or Query.
Some people like to have Unbound Forms and then manipulate the records using VBA, which is very hard work.
Reply

Tags
access, access 2007, form, vba

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:03 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.