Results 1 to 14 of 14
  1. #1
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389

    coding problem


    I have done coding in the student name box of this program under which when the cursor goes to this box and this box is empty then the message of "hello" should come but it is not coming.
    Attached Files Attached Files

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Looks like a continuation of this thread
    https://www.accessforums.net/showthr...231#post516231

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Try this:-



    Private Sub Student_Name_GotFocus()


    If (IsNull(Me.Student_Name)) Then


    MsgBox "Enter a name", vbCritical
    End If


    End Sub

    But can you also explain why you need to do this?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  4. #4
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    thanks.. it working
    what was the difference between you coding and mine?
    My main reason is other it's just a sample program...

  5. #5
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by CJ_London View Post
    Looks like a continuation of this thread
    https://www.accessforums.net/showthr...231#post516231
    That was another problem involving numeric and string problems which had been solved.

  6. #6
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    This line:-

    If (IsNull(Me.Student_Name)) Then
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  7. #7
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by mike60smart View Post
    This line:-

    If (IsNull(Me.Student_Name)) Then
    yes it worked
    but i asking that what is difference between in this

    if (IsNull(Me.Student_Name)) then
    and
    if Me.Student_Name.Value = Null then

  8. #8
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Well

    = Null does not work
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by deepaksharma View Post
    yes it worked
    but i asking that what is difference between in this

    if (IsNull(Me.Student_Name)) then
    and
    if Me.Student_Name.Value = Null then
    Nohing is equal Null, that is beauty of Null.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Welshgasman View Post
    Nohing is equal Null, that is beauty of Null.

  11. #11
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389

    what is difference in this_____

    if (IsNull(Me.Student_Name)) then
    and
    If (IsNull(Me![Student_Name].Value)) Then
    and
    If Me.Student_Name = "" Then

    Please explain any expert......

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    .Value is the default property for a control so first two are the same.
    Null is not = "" (already told you that), hat is called a Zero Length String (ZLS)

    You could try
    Code:
    If Me.Control & "" = "" Then
    or test same for Length = 0

    Not an expert, but thought I'd have a punt.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  13. #13
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    The first two are quite similar but for the use of Me! vs Me.
    Me! will not compile and will only evaluate at run time. If what follows ! cannot be resolved (e.g. due to a spelling error) it will only trigger an error when it tries to execute that line.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  14. #14
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    thansk to all....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Coding problem
    By deepaksharma in forum Access
    Replies: 16
    Last Post: 09-08-2023, 06:08 AM
  2. Coding Problem - Too few parameters
    By JJPetersen1 in forum Programming
    Replies: 2
    Last Post: 08-16-2023, 10:32 AM
  3. Problem Coding this IIF statement
    By wcrimi in forum Queries
    Replies: 4
    Last Post: 03-20-2017, 09:33 AM
  4. Coding problem with Exit button
    By NightWalker in forum Programming
    Replies: 11
    Last Post: 06-06-2016, 01:05 PM
  5. Coding problem.
    By cheyanne in forum Forms
    Replies: 3
    Last Post: 05-19-2012, 05:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums