Minggu, 01 Januari 2017

Re: [MS_AccessPros] Default Value

 

David-


You can't use Select Case that way.  For example, your first Case clause is asking if Me.txtSpecialTests = IsNull(Me.txtSpecialTests), which of course will be false.  You need to use a simple If:

    If IsNull(Me.txtSpecialTests) Or Me.txtSpecialTests = "" Then
        Me.txtBottlesRequired = Me.cboSelectedGridID.Column(3)
    Else
        Me.txtBottlesRequired = CInt(Me.cboSelectedGridID.Column(3)) + 1
    End If

I added the convert because the columns in a combo box are always Text data type.

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Jan 1, 2017, at 7:53 AM, david.pratt@outlook.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



I am trying to set a default value into a "bottles required" text box control based on the value of the fourth column of a combo box.  I was able to do that successfully.  However, there is another text control txtSpecialTests that will affect the number of bottles required.  Basically, if there any special tests in the txtSpecialTests control, I want to add 1 to the value in column 4 of the combo box.  If txtSpecial tests is empty or null, I don't want to add 1. 

I have the following code in the AfterUpdate event of the combo box:
Private Sub cboSelectedGridID_AfterUpdate()
    Select Case Me.txtSpecialTests
        Case IsNull(Me.txtSpecialTests)
            Me.txtBottlesRequired = Me.cboSelectedGridID.Column(3)
        Case Me.txtSpecialTests = ""
            Me.txtBottlesRequired = Me.cboSelectedGridID.Column(3)
        Case Else
            Me.txtBottlesRequired = Me.cboSelectedGridID.Column(3) + 1
    End Select
        
End Sub

It adds 1 every time, no matter whether the txtSpecialTests control is empty, null or not.





__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (11)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar