Senin, 14 November 2016

Re: [MS_AccessPros] Set date type fields settings

 

John,

There is some Syntax Error in this line i could not find that

If strMonth Not In ("jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec") Then

Please check again.

Regards,
Khalid


On Monday, November 14, 2016 10:57 PM, "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:


 
Khalid-

If you want to look at what the user typed, you need to look at the .Text property of the control.

Dim strMonth As String

    strMonth = Left(Me.MfgDate.Text, 3)
    If strMonth Not In ("jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec") Then
        MsgBox "You must enter a valid month abbreviation: " & vbCRLF & _
           "Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec"
        Cancel = True
    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 Nov 14, 2016, at 6:09 PM, Khalid Tanweer khalidtanweerburrah@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



John,
Form "Item File" has Record Source table "ItemFile". I cleared Format property for field MfgDate in the table and also on the Forms Control "MfgDate". Input Mask is LLL\-0000;0;
Now when i entered "Jan-2016" it returned 01/01/2016, also what condition should be written on the code 

Private Sub MfgDate_BeforeUpdate(Cancel As Integer)
    If MfgDate ............... Then
        MsgBox ".............", vbExclamation, "..........."
    End If
    Me.Undo
End Sub

Regards,
Khalid


On Monday, November 14, 2016 9:41 PM, "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:


Khalid-

Does it work if you clear the Format property?  It sounds like Access is using that setting to grab the invalid data before your code gets a chance.

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 Nov 14, 2016, at 5:25 PM, Khalid Tanweer khalidtanweerburrah@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



John,

Yes i am trying Before Update event on the Control.
And just for reminder now i am using Access 2007.

One more thing my Access Help is not working i dont know what happened. I ran Microsoft Office Diagnostics and it tells everything is OK.
Regards,
Khalid


On Monday, November 14, 2016 7:31 PM, "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:


Khalid-

Are you trying to do the intercept in BeforeUpdate of the control?  I think that should work.  If you're using the Form's BeforeUpdate, that's too late.

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 Nov 14, 2016, at 2:16 PM, Khalid Tanweer khalidtanweerburrah@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



Hi All,
I have two controls on Form "Item File"
MfgDate
ExpDate

Having Input Mask--> 00/00/0000;0;_
Format--> mmm-yyyy

Currently i have to enter date like 01/01/2016. I need to enter data like Jan-2016 and set
the check if month is mis-spelled i.e apart from Jan to Dec, my custom msgbox should open.
I did tried with input mask--> LLL\-0000;0; and was able to enter like Jan-2016 but i was
unable to display my custom msgbox if month part is mis-spelled, Access opens its built in message
As below:
The value you entered isn't valid for this field.
For example, you may have entered text in a numeric field or a number that is larger than the FieldSize setting permits.

Help required please.
Regards,
Khalid















__._,_.___

Posted by: Khalid Tanweer <khalidtanweerburrah@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (7)

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