Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 19th, 2006, 05:56 AM
Friend of Wrox
 
Join Date: Apr 2006
Location: Ternat, , Belgium.
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default update a fields value

Hi,

just have another question. I tried to find the solution myself, but it does not work...

What I would like to do is: When I choose a value from a combo box, the value of a check box on the same form should remain 'No' or be changed to 'Yes' according to the value I choose in the combo box.

When the value 'onvolledig ingevuld' is chosen, the check box should remain on the 'No' value, when the value in the combo box is deleted (because the wrong record was chosen for exemple) the value should stay (or come back to) 'No' also. In every other scenario, the value of the combo box should be changed to 'Yes'

The code I'm using is:

Private Sub Nummer_code_AfterUpdate()
    On Error Resume Next
    Select Case Nummer_code.Value
        Case "Onvolledig ingevuld"
            TT_terug.Value = 0
        Case Isnull
            TT_terug.Value = 0
        Case Else
            TT_terug.Value = -1
    End Select
End Sub

where 'Nummer_code' is the combo box of course and the name of the check box is 'TT_terug'. What is wrong with this code? What should I do to make this work???

Thanks

Reply With Quote
  #2 (permalink)  
Old May 19th, 2006, 06:39 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   Me again.

   You need to put this code it two places, one on the after update event of the combo box, and the other on the On Current event of the form. Then I would suggest taking the value in the combo box as a variable instead of taking it right from the combo box in your select case statements.

Also, please make sure the combo box bound column is a string, as you indicate here. If it is a number, then you need to call Column(1).

Something like:

Private Sub Nummer_code_AfterUpdate()
    'On Error Resume Next remove this line

    Dim sValue As String

    If IsNull(Me.Nummer_code) Or Me.Nummer_code = "" Then
        Me.TT_terug = 0
        Else
        sValue = Me.Nummer_code.Column(1)
        If sValue = "Onvolledig ingevuld" Then
           TT_terug = 0
           Else
           TT_terug = -1
        End If
    End If
End Sub


Anywho, if you are only using the check box as an automated control, there is not really a need for it since this check can be done in subsequent queries. If you must have the check box on the form, and it is only to be used when it is automated, be sure to set it to Enabled = No, Locked = Yes.

Did that help?


mmcdonal
Reply With Quote
  #3 (permalink)  
Old May 19th, 2006, 06:41 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, in the second nested conditional, it should have been:

       If sValue = "Onvolledig ingevuld" Then
           Me.TT_terug = 0
           Else
           Me.TT_terug = -1
        End If


mmcdonal
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Table fields karajian Access VBA 2 December 7th, 2004 03:48 PM
Problem to update fields cilla Classic ASP Databases 22 October 26th, 2004 07:36 AM
Update multiple fields. slgknjn Classic ASP Databases 6 February 15th, 2004 10:26 AM
fields from tables to update damnnono_86 Access 3 November 5th, 2003 04:07 AM



All times are GMT -4. The time now is 11:25 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.