473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Update all Selected Records

Hi,
I am working with access 2003 / XP and this is my first post to the forum and I am pretty new to Access.

I have a Main single form with a subform built in. I would like to add a button on the main form that will change the yes/no fields in the records on the subform to yes. Also, if there is a filter applied, I only want to update those records that are filtered. The filters would only be of "right click-filter by selection" variety.

The fields on the subform are as follows:

Manuf_Na
Manuf_Cat
Prod_Desc
Class_Desc
Excl_Ln (Yes/No)

Probably a simple solution, but I couldn't find any info anywhere else. Any thoughts are greatly appreciated.

Mike
Oct 31 '07 #1
5 4134
nico5038
3,080 Expert 2GB
The update can be coded in VBA and use a defined filter like:
Expand|Select|Wrap|Line Numbers
  1. IF Me.SubformName.Form.FilterOn = True then
  2.    ' filter has been specified
  3.    currentdb.execute ("UPDATE tblX SET Excl_Ln = True WHERE [MainID]=" & ME.MainID & " and " & Me.SubformName.Form.Filter)
  4. else
  5.    ' NO filter has been specified
  6.    currentdb.execute ("UPDATE tblX SET Excl_Ln = True WHERE [MainID]=" & ME.MainID)
  7. end if
  8.  
Getting the idea ?

Nic;o)
Oct 31 '07 #2
Nico - Thank you for your response. I started to work with the code you provided and here is what I came up with - It keeps resulting in a runtime 3075 error, missing operator? Not sure what I am missing here. Thanks again.

If Me.tblUtilizationDataAll_subform.Form.FilterOn = True Then
' filter has been specified
CurrentDb.Execute ("UPDATE tblUtilizationDataAll SET Exclude_Line = -1 WHERE [PROJECT_NAME] = " & Me.Text81 & " And " & Me.tblUtilizationDataAll_subform.Form.Filter)
Else
' NO filter has been specified
CurrentDb.Execute ("UPDATE tblUtilizationDataAll SET Exclude_Line = -1 WHERE [PROJECT_NAME] = " & Me.Text81)
End If
Nov 1 '07 #3
nico5038
3,080 Expert 2GB
Nico - Thank you for your response. I started to work with the code you provided and here is what I came up with - It keeps resulting in a runtime 3075 error, missing operator? Not sure what I am missing here. Thanks again.

If Me.tblUtilizationDataAll_subform.Form.FilterOn = True Then
' filter has been specified
CurrentDb.Execute ("UPDATE tblUtilizationDataAll SET Exclude_Line = -1 WHERE [PROJECT_NAME] = " & Me.Text81 & " And " & Me.tblUtilizationDataAll_subform.Form.Filter)
Else
' NO filter has been specified
CurrentDb.Execute ("UPDATE tblUtilizationDataAll SET Exclude_Line = -1 WHERE [PROJECT_NAME] = " & Me.Text81)
End If
I guess your Project_Name is a extfield, thus the value needs to be embedded in single quotes (') like:
Expand|Select|Wrap|Line Numbers
  1. [PROJECT_NAME] = '" & Me.Text81 & "' And " &
  2. 'and in the "else" branch
  3. [PROJECT_NAME] = '" & Me.Text81 & "'") 
  4.  
Nic;o)
Nov 1 '07 #4
Nico - Thank you again for all of your help. The other branch of this code works, however this string is resulting in a runtime 3061 - Too few parameters. Expected 1 when a filter is on in the subform. I can't figure out why?
Expand|Select|Wrap|Line Numbers
  1. CurrentDb.Execute ("UPDATE tblUtilizationDataAll SET Exclude_Line = -1 WHERE [PROJECT_NAME] = '" & Me.Text81 & "' And " & Me.tblUtilizationDataAll_subform.Form.Filter)
  2.  
Nov 2 '07 #5
nico5038
3,080 Expert 2GB
Best to place a breakpoint (click in left "ruler" so a dot appears) and execute the code till the command. Now type in the immediate window the line:

? "UPDATE tblUtilizationDataAll SET Exclude_Line = -1 WHERE [PROJECT_NAME] = '" & Me.Text81 & "' And " & Me.tblUtilizationDataAll_subform.Form.Filter)

By pressing enter on that line the created code will appear and check that for the fieldnames as the message indicates that a tablefield isn't found in tblUtilizationDataAll.

Nic;o)
Nov 2 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old...
7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
5
by: A.Dagostino | last post by:
hi i need to update an SQL Table when user select or unselect a checkbox control. How Can i do? Thanks Alex
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
1
by: Wolffang | last post by:
From: "Wolffang" <javid@techlite.co.uk> Subject: How to do a multiple select and update in a datagrid Date: 23 October 2004 21:28 Using Visual studio.net VB I have a datagrid that brings...
11
by: Siv | last post by:
Hi, I seem to be having a problem with a DataAdapter against an Access database. My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable. I then proceed to update a list to...
3
by: Roy | last post by:
Hi Access gurus, I have a A2K application.The data in the database is updated daily by a excel download.I have a master n related tables keyed in by a OrderID.I have a problem in updating data.If...
2
daniel aristidou
by: daniel aristidou | last post by:
Hi can anyone help me with the logic of updating records that are selected in a datagrid. Just wanna be sure before i code it all, since its first time im doing this and making sure the logic is...
3
by: Sam Durai | last post by:
A simple update involving two small tables takes 45 minutes to complete. I would appreciate if you can kindly help me to understand the root cause of this slowness. Users would be happy if I can...
6
by: mukeshrasm | last post by:
Hi I want to update records in database based on selected records using checkbox. if user does not select a record and clicks update button it should show the message please select record to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.