Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Update a field based on whether a button is checked or not

Posted on 2013-10-30
4
Medium Priority
?
279 Views
Last Modified: 2013-10-30
I have this form that needs to do the following

When the checkbox named "Assigned" is checked I need the field "ContolTNum " to be assigned the value from a second form named Forms!frm1POSControlTicket!ControlTicketNum. When the button is unchecked the field should be null

currently the code I have is as follows

Private Sub Assigned_Click()
Me.Refresh
Forms!frm_qry_tbl_visa_imports!ContolTNum = Forms!frm1POSControlTicket!ControlTicketNum

End Sub

Open in new window


Obviously as you can guess everytime i check or uncheck the box, the field updates to the set value. I do need to add some logic that when the button is unchecked to convert the field back to null (not assign a value to the field.

thanks
Vinnie
experts1.JPG
0
Comment
Question by:damixa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 39612752
Try this:

Private Sub Assigned_Click()
Me.Refresh
If Me.Assigned = true then
    Forms!frm_qry_tbl_visa_imports!ContolTNum = Forms!frm1POSControlTicket!ControlTicketNum
Else
    Forms!frm_qry_tbl_visa_imports!ContolTNum = Null
End if 
End Sub

Open in new window

0
 

Author Comment

by:damixa
ID: 39612759
Hi,
The problem is that it does not go back to null once i Uncheck it

I need it to go null once i Uncheck "Assigned
0
 

Author Comment

by:damixa
ID: 39612762
Perfect, sorry my bad, I didnt read the whole code
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39612763
Also - I think I mentioned this in another question - you do not need the full form reference if the code is on the same form:

Try this if the code is on frm_qry_tbl_visa_imports:

Private Sub Assigned_Click()
Me.Refresh
If Me.Assigned = true then
    Me.ContolTNum = Forms!frm1POSControlTicket!ControlTicketNum
Else
    Me.ContolTNum = Null
End if 
End Sub

Open in new window


Or this if it is on frm1POSControlTicket:

Private Sub Assigned_Click()
Me.Refresh
If Me.Assigned = true then
    Forms!frm_qry_tbl_visa_imports.ContolTNum = Me.ControlTicketNum
Else
    Forms!frm_qry_tbl_visa_imports.ContolTNum = Null
End if 
End Sub

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question