[AccessD] Setting default value of a text box

Kaup, Chester Chester_Kaup at kindermorgan.com
Wed Apr 3 13:44:30 CDT 2013


The code runs but returns the value ""RWLS"" to Me.[Invoice Number].DefaultValue. My understanding is that if a text box is assigned a default value any additional characters typed into the text box would be appended to the default value. For example if 1234 is entered then Invoice Number in the underlying table should have the value RWLS1234 but only 1234 is being stored. I am confused.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Wednesday, April 03, 2013 11:43 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Setting default value of a text box

Hi Chester

You probably need a set of outer quotes:

Private Sub CompanyName_AfterUpdate()
    Dim Company As String
    Company = Me.CompanyName.Value
    Me.[Invoice Number].DefaultValue = IIf(Company = "Renegade", Chr(34) & "RWLS" & Chr(34), "") End Sub

/gustav


-----Oprindelig meddelelse-----
Fra: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] På vegne af Kaup, Chester
Sendt: 3. april 2013 15:23
Til: Access Developers discussion and problem solving
Emne: Re: [AccessD] Setting default value of a text box

I tried placing the following code in the after update event of the text box Company Name but it seems to do nothing. This is the first text box on the form that accepts data. What am I doing wrong?

Private Sub CompanyName_AfterUpdate()
    Dim Company As String
    Company = Me.CompanyName.Value
    Me.[Invoice Number].DefaultValue = IIf(Company = "Renegade", "RWLS",
Null)
End Sub


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list