Solved

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

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

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…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

920 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

14 Experts available now in Live!

Get 1:1 Help Now