473,473 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Subform datasheet: select one record to update form?

AccessIdiot
493 Contributor
Hello all,

I have a form with a subform in datasheet view. The subform shows name and phone number and a checkbox that says "use this contact". When selected, the name and number populate text fields on the main form.

The problem is that if the subform contains multiple records, the checkbox for each can be selected. The form holds the values of the last selected, but I'd like for there to be only one check - that is, if a user selects one, and then another, the first should automatically uncheck.

Code on subform:
Expand|Select|Wrap|Line Numbers
  1. Private Sub chkUseThisContact_AfterUpdate()
  2.   If Me!chkUseThisContact Then
  3.     Forms!frm_LandownerContact.LandownerContact = Me.FullName
  4.     Forms!frm_LandownerContact.LandownerPhone = Me.Phone
  5.   Else
  6.     Forms!frm_LandownerContact.LandownerContact = Null
  7.     Forms!frm_LandownerContact.LandownerPhone = Null
  8.   End If
  9.   Me.Requery
  10. End Sub
** Edit **

Attached Images
File Type: jpg Screenshot_1.jpg (27.2 KB, 885 views)
Sep 29 '11 #1
5 3630
Rabbit
12,516 Recognized Expert Moderator MVP
Run an update query to uncheck every record in the subset of records.
Then run an update query to recheck the chosen contact.
Finally, requery the subform.
Sep 29 '11 #2
AccessIdiot
493 Contributor
Thanks for the quick response. Can you please ignore the fact that I have 491 posts on this site and pretend that I am the newbiest of all newbs?

I'm not even sure where to begin creating an update query.
Sep 29 '11 #3
NeoPa
32,556 Recognized Expert Moderator MVP
Hey M. Good to hear from you again :-)

UPDATE queries can be created in the query design view if you change the type of the query using either the Query Type button in the toolbar or select Update Query from the Query menu. These can also be created in SQL directly in your code (Put the SQL code into a string) and executed (Call CurrentDb.Execute(strSQL)) from there too.

That said, there is an alternative to using an action query on your data, which is to manipulate the data from either the Recordset or RecordsetClone properties of the form. The benefit of this latter approach would be that it avoids having to requery the data and thereby lose (or have to implement extra code to avoid losing) the settings of where you are on the form within the dataset.

If you'd like, and can send me a copy of your database (You can attach here if you prefer or have lost my email address - See Attach Database (or other work)), I'll look at it for you and see if I can post a suggestion in the specific terms of the database.
Sep 29 '11 #4
AccessIdiot
493 Contributor
Thanks A, I'll have a look at the properties, then contact you. :-)
Oct 3 '11 #5
NeoPa
32,556 Recognized Expert Moderator MVP
8 - )
Oct 3 '11 #6

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

Similar topics

5
by: R Duncan | last post by:
Hi, I'm considering moving a payroll application out of Microsoft Access to some web-based solution. It is getting way to big for Access and the system is growing unstable, so I'm learning PHP...
1
by: edself | last post by:
I have a form which displays a subform datasheet of information. I'd like to be able to quickly click on a particular record and open up another form showing more detailed information about that...
3
by: deko | last post by:
I have a form with a subform datasheet - I need code behind the OnDelete event of the subform: Private Sub Form_Delete(Cancel As Integer) 'do something that depends on which record is deleted...
1
by: BartonConstruction | last post by:
Greetings all, I have a main form (frmClients) with two subforms (subVisits) (subAccount). I got the subforms to reflect what the main form is showing by linking master and child fields (I...
8
by: erick-flores | last post by:
Hello all My code used to work, but now its not working any more. What I am trying to do is find the current user when a forms open. This is the code that used to work: If...
4
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form...
11
by: cooperkuo | last post by:
Dear all, I have a question about ADO in the subform. I know how to use ADO to insert/update/select data into the sigin form, but wehn I try to do it in the form with subform((Datasheet). I don't...
14
by: BASSPU03 | last post by:
(I'm using Access 2003 on a Windows XP O/S.) I've gotta present an update on my database this week--possibly within the next 24 hours. A solution or guidance to this inquiry would really, really...
1
by: menkenk | last post by:
Good Afternoon, I currently have an issue in trying to get a macro working for clicking a record in a subform datasheet to open a form with the complete record details of that specific record....
10
stonward
by: stonward | last post by:
I select a product on a listbox that includes the Primary Key. I want to open another form, once a product is selected, with the subform of the newly opened form displaying the selected product...
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.