473,804 Members | 3,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

control a primary checkbox on a continuous subform

Ok I have 2 issues.

1) I have a main candidate form with 2 subforms on a tab control:
http://www.geocities.com/misscrf/ima...uscheckbox.jpg
I have been encouraged to add these checkboxes, so that when there is
more than one phone or address for a candidate, I can track which is
the primary.

My issue is that I have to control that only one address, for example,
can be a primary for one candidate. Can anyone help me in how to go
about controlling that?

My thought is something along these lines, but I could use help with
the specifics, ie code to do it. I was thinking that per candidate, I
have code in the on change or click of the yes/no checkbox. It
evaluates if there is a 1 ( yes) for any address records for the
candidate. If so, then a message " This candidate has a primary
address. Would you like to change it?" Response if yes, then make all
checkmarks for addresses for that candidate null, so that they can
make one checked. If no, then leave as is. If there is no address
with a checkmark, then the intial check can either just check, or pop a
message (ok) that says, " This address will be made the primary address
for the candidate"

Can anyone help with that?

I think I want to post my other question, but maybe I will wait and do
one at a time.

Thanks!

Nov 13 '05 #1
4 1861
ABG


to change it
on the before update event for the checkbox:
where persID is the PK

docmd.runsql " update contactInfo set PrimaryContact = 0 where persID =
' " & me.persid.value & " ' "

it should run this to clear any PrimaryContacts for that person to 0
before your record is saved.

Nov 13 '05 #2
Thanks. I will remember that. I jotted it down. Now I need to work
out the intial check of one record, and the evaluation of the check
instance if it is a 2nd check etc.

Nov 13 '05 #3
jv
I have a custom lookup function that I always use, but you can use the
builtin DLookup function to do the checking:

if isnull(DLookup( "isPrimary","tb lAddresses","Ap plicantID=" &
me!ApplicantID & " isPrimary=True" )) then
' did not find any primary address, write code to make this one the
primary
else
if vbYes=msgbox("T his candidate has a primary address. Would you
like to change it?",,vbquestio n+vbYesNo,"Chan ge Primary Address") then
'clear the existing check box
DoCmdRunSQL"Upd ate tblAddresses SET isPrimary=false WHERE
ApplicantID=" & me!ApplicantID & " isPrimary=True"
'write code to make this one the primary
end if

Nov 13 '05 #4
I will look at your code to see if it will work better than what I have
started. This is what I have now:

I put this code in the afterupdate of the primary checkbox:

Private Sub Primary_AfterUp date()
On Error GoTo Err_Primary_Aft erUpdate
If Not DCount("[Primary]", "tblAddress ", "[CandID] = " & Me.anCandID &
" AND Primary = True") Then
Me.Primary = True
ElseIf Me.Primary = True Then
DoCmd.RunSQL "Update tblAddress Set Primary = False Where CandID = "
& Me.anCandID
Dim Msg, Style, Title
Msg = "You must specify which address is the primary address.
Please do that now. Thank you."
Style = vbOK
Title = "Candidates with multiple addresses must have a primary
address."
Response = MsgBox(Msg, Style, Title)
DoCmd.GoToContr ol [Primary]
End If

Exit_Primary_Af terUpdate:
Exit Sub

Err_Primary_Aft erUpdate:
MsgBox Err.Description
Resume Exit_Primary_Af terUpdate

End Sub

----------------------

This is the error I get when I click on the checkbox:

Syntax error (missing operator) in query expression 'CandID = AND
Primary = True'.

I think they truncated the query criteria of the code there.

Anyway, after you click ok to the error, it checks the box anyway and
lets you move on.
I am not sure where to go from here...

Nov 13 '05 #5

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

Similar topics

3
4176
by: Not Me | last post by:
Hi, Just trying to get my head around tab controls, is there anywhere which would describe the structure of how they work? I seem to be ok so far, being able to check which page I'm on etc... but I'm at a loss when trying to access controls inside the tabs. If I try to access the form directly (!...etc.) I get an error that the form can't be found. I'm not sure how I can use parent/child relationships to get at the (sub)forms which...
9
7433
by: Jack | last post by:
In the control source of a textbox, is there a way to refer to a column of a combobox? For example: =.Column(2) Thanks, Jack
3
1841
by: Kranman | last post by:
Hi All, Love this site, have gotten a lot from it. This is my first time posting though, so forgive me for any errors. I have an Access 2000 db where I have a main form of Contractors and on the main form is a subform of bonds carried by those contractors. I am trying to reference a field named "Bond" located on the subform in code that is run from the mainform and am having trouble with the syntax for this. Below is a sample of...
1
2939
by: gavo | last post by:
Hello everyone! Using A2K i have a form(a) with a subform(b) and within the subform there is a continuous subform(c). in the subform (b) there is a command button used to call a public function
6
3804
by: MLH | last post by:
When the vehicle entry form (frmVehicleEntryForm) first opens, the additional owner SubForm control (frmAddnlOwnrListSubForm) is enabled. You can click on it and it will accept the focus. But after you enter data to the first field on the main form (a VIN#), that is not the case. The SubForm control becomes disabled and will not accept the focus. Dunno why. There's no child/master link fields. They have no settings - at least not in design...
2
4981
by: dBNovice | last post by:
Hello All, I could really use some serious help with this one... I have a form that has a tab control with 3 pages. Page(0) is Tasks, Page(1) is SubTasks, and Page(2) is Elements. Page (1) is a subform of page (0); linked with TaskID and page (2) is a subform of page (1); linked with SubtaskID. I want to be able to have multiple subtasks for some tasks; and multiple elements for some subtasks. The relationship has been set...
6
2263
by: cefrancke | last post by:
I've read up on Access and the limits of creating visible controls at run-time. I'm using Access 2003 and assume that it cant be done. I did find a clever method of having a main form (and in it's code) open up a subform in design mode (hidden maybe) and then using the CreateControl method, create controls. Save the subform and set a subform control on the main form to point to the subform (really a form) I just edited/designed.
5
2306
by: MOC835 | last post by:
I have calendar control that I am trying to use on a continuous subform to select two dates. My MainForm collects user data, and the continuous SubForm collects two dates for that specific user...an IssueDate and a ReturnDate. I am trying to give the user the option of entering the date into the date field text box, or clicking a button next to the text box to open a seperate form with a calendar in it (frmCalendar).
1
2017
by: Thuveshen | last post by:
Hi There I am new to VB scripting in MS Access. I currently have a form with a subform embedded in it. I run a query based on search criteria which works fine. Within the Subform there is a checkbox (Paid) that is displayed for each record. I want to enable the AmountPaid textbox for that INDIVIDUAL record, when the checkbox is True. At the moment when I enable the checkbox for one record, ALL the Amount Paid textboxes for each...
0
9705
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
9576
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,...
0
10323
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10311
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,...
1
7613
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
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
5516
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4292
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
3813
muto222
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.