Solved

How update field in an unbound table

Posted on 2011-09-12
5
347 Views
Last Modified: 2013-11-05
I have a form with a text box and a checkbox.  The form is unbound.  The textbox is named "txtJobN" and the checkbox is named "chkbxUrgent".  The user first enters a number in the "txtJobN" field.  Then they either check or uncheck the checkbox.  When they check or uncheck the checkbox I want the onclick event of the checkbox to update a record in tblJob where the key field equals the value in "txtJobN".

How?
0
Comment
Question by:SteveL13
  • 3
5 Comments
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 125 total points
ID: 36523644
First, I would recommend changing txtJobN to a combo box, with a row source of valid Job numbers.  This will avoid frustration for the users.  Then run this code from the checkbox's AfterUpdate event (I am assuming that you want the update to occur only when the checkbox is checked).  Of course, you will need to add code to to the actual updating, as indidated in the code.
Private Sub chkUrgent_AfterUpdate()

   Dim strJobNo As String
   Dim rst As DAO.Recordset
   Dim strSearch As String
   
   If Me![chkUrgent].Value = True Then
      strJobNo = Nz(Me![txtJobNo].Value)
      
      If strJobNo <> "" Then
         Set rst = CurrentDb.OpenRecordset("tblJobs", dbOpenDynaset)
         strSearch = "[JobNo] = " & Chr(39) & strJobNo & Chr(39)
         rst.FindFirst strSearch
         If rst.NoMatch = False Then
            rst.Edit
            'Your update code here
            rst.Update
         End If
      End If
   End If
   
End Sub

Open in new window

0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 36523665
For the updating code, you need a field name, and a value to assign to it.  You may need to add more controls to your form to get this information.
0
 

Author Comment

by:SteveL13
ID: 36523812
Ok.  I have changed the field to a combobox.  When the user selects a record from the list I still need to update that record's "Urgent" field as true or false depending on what the user did with the checkbox which is named "chkbxUrgent".  I am not sure how to accomplish this.
0
 
LVL 26

Assisted Solution

by:Nick67
Nick67 earned 125 total points
ID: 36525592
You aren't sure about this part?

         If rst.NoMatch = False Then
            rst.Edit
            'Your update code here
            rst.Update
         End If

it would be
    rst!WhateverFieldYouWantChanged = Me.chkUrgent.Value

         If rst.NoMatch = False Then
            rst.Edit
            rst!WhateverFieldYouWantChanged = Me.chkUrgent.Value
            rst.Update
         End If
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 36530948
If Nick's comment is correct, then you need to remove the portion of my original code that proceeds only if the checkbox has a True value.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2016 5 53
SQL - Cumulating field values to one field 5 19
Access query expression 6 19
update all email addresses SQL 1 23
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now