Rabu, 14 Desember 2016

Re: [MS_AccessPros] Need code correction

 

Kambiz-


No, a single quote surrounded by double quotes.

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 Dec 14, 2016, at 6:59 PM, Kambiz Afshartous kenaf42@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



It works fine. Just one question, did you use two quotes and one apostrophe?
 
Kambiz



From: "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com> 
Sent: Tuesday, December 13, 2016 3:02 PM
Subject: Re: [MS_AccessPros] Need code correction

Close, but no cigar.  Like this:

Private Sub ComPayCode_AfterUpdate(Cancel As Integer)
If Not IsNull(Me.ComPayCode.Value) Then
 ComPayCode.DefaultValue = "'" & Me.ComPayCode & "'"
 End If


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 Dec 13, 2016, at 8:45 PM, Kambiz Afshartous kenaf42@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



John thanks as always. Then is the following correct for the Text Box?

Private Sub ComPayCode_AfterUpdate(Cancel As Integer)
If Not IsNull(Me.ComPayCode.Value) Then
 ComPayCode.DefaultValue = "" & Me.ComPayCode & ""
 End If
 
Kambiz



From: "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
To: "MS_Access_Professionals@yahoogroups.com" <MS_Access_Professionals@yahoogroups.com> 
Sent: Tuesday, December 13, 2016 1:40 PM
Subject: Re: [MS_AccessPros] Need code correction

Ken-

It looks like you're trying to set the Default Value for the next new row based on what is set in the current one.  For that, you should be using AfterUpdate, not Before.  And why are you putting hashtags around the value?  You need to do that only when the value is a datetime.  If the value is text, you need to add quotes.

As for DropDown - it's a long-standing bug in Access that it works in some combos but not all.

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 Dec 13, 2016, at 7:31 PM, kenaf42@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



Access 2010
1.       1. I use the following code on form it works fine in Text Box but it does not work in combo box why?
Private Sub ComPayCode_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.ComPayCode.Value) Then
 ComPayCode.DefaultValue = "#" & Me.ComPayCode & "#"
 End If
 

2.       2. Also this simple code in GotFocus:  Me!ComboboxName.Dropdown works on some of combo boxes but not on all.

 
Thanks, Ken













__._,_.___

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 (6)

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