Solved

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

Posted on 2013-10-30
4
268 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 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now