Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-10-30
4
Medium Priority
?
282 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
  • 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

926 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