Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389

    Coding problem

    When I select Muslim or Buddha in cast box of main form then why it does not send "hello" message?
    File
    https://drive.google.com/file/d/1Bfr...w?usp=drivesdk

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Many responders will not download from sites other tab this forum. Recommend you attach your example here (go to the advanced tab)

    better still, copy paste your code and use the code tags

  3. #3
    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
    Many responders will not download from sites other tab this forum. Recommend you attach your example here (go to the advanced tab)

    better still, copy paste your code and use the code tags
    on your demand, but this method show file error....
    Attached Files Attached Files

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    nothing appears and there is no code for the castcode control

  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
    nothing appears and there is no code for the castcode control
    code written in save button

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    1. learn to indent your code - it will be easier to read and follow

    2. learn to use debug.print - or step through the code to check the values as you go

    3. to use debug.print put the following code before your 'If RST.Fields(3) = Me.castcode.Column(1) Then' line

    debug.print RST.Fields(3)
    debug.print Me.castcode.Column(1)

    results will appear in the immediate window

    that will tell you what the problem is

  7. #7
    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
    1. learn to indent your code - it will be easier to read and follow

    2. learn to use debug.print - or step through the code to check the values as you go

    3. to use debug.print put the following code before your 'If RST.Fields(3) = Me.castcode.Column(1) Then' line

    debug.print RST.Fields(3)
    debug.print Me.castcode.Column(1)

    results will appear in the immediate window

    that will tell you what the problem is
    its not show any error

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    what do you see in the immediate window when the debug is executed?

  9. #9
    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
    what do you see in the immediate window when the debug is executed?

    i changed my code and tried with this code
    Debug.Print RST.Fields(3)
    Debug.Print Me.castcode.Column(0)
    If RST.Fields(3) = Me.castcode.Column(0) Then

    and immediate window show
    4
    2
    2
    2

    all is right but i don't know why coding not working as i wish.

  10. #10
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    think about it - you original code referenced column 1, now you are referencing column 0

  11. #11
    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
    think about it - you original code referenced column 1, now you are referencing column 0
    yes i have corrected my mistake but still problem

  12. #12
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Your problem was the hello msgbox not showing- are you saying it still isn’t showing?

  13. #13
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Yes it is not showing

  14. #14
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Problem 1
    This Set RST = DB.OpenRecordset("main") will open an unfiltered recordset and RST.Fields(3) will be equal to some random value - probably the first record, which is 4.

    Problem 2
    Even when the code is 4 and the recordset field value is 4, your code is not producing the desired result. That is because for some reason, one is 4 and the other (column) is "4".
    This would be obvious if you followed the advice and suggestions you are given:
    step through the code to check the values as you go
    Click image for larger version. 

Name:	1castCode.jpg 
Views:	24 
Size:	6.0 KB 
ID:	50747
    Note the quote marks around the 4 when I mouse over that line - the 4 is text. If you had asked me, I would have said that it should work, but discovering that one is text and the other is a number can lead to a solution.
    This could fix it: If RST.Fields(3) = CLng(Me.castcode.Column(0)) Then

    If there is a reason why the code is being regarded as text it is unknown to me at the present time. Your table field data types are long so that is correct.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  15. #15
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Micron View Post
    Problem 1
    This Set RST = DB.OpenRecordset("main") will open an unfiltered recordset and RST.Fields(3) will be equal to some random value - probably the first record, which is 4.

    Problem 2
    Even when the code is 4 and the recordset field value is 4, your code is not producing the desired result. That is because for some reason, one is 4 and the other (column) is "4".
    This would be obvious if you followed the advice and suggestions you are given:


    Click image for larger version. 

Name:	1castCode.jpg 
Views:	24 
Size:	6.0 KB 
ID:	50747
    Note the quote marks around the 4 when I mouse over that line - the 4 is text. If you had asked me, I would have said that it should work, but discovering that one is text and the other is a number can lead to a solution.
    This could fix it: If RST.Fields(3) = CLng(Me.castcode.Column(0)) Then

    If there is a reason why the code is being regarded as text it is unknown to me at the present time. Your table field data types are long so that is correct.
    Thank you very much for solving the problem. You have solved this problem but still somewhere I have a doubt in my mind I will give you five star rating now another question has arisen in my mind that why it is accepting a numeric value in text so I am not able to mark this question as solved, I leave this question on continue, maybe some other expert will come and solve our problem. Thank you very much again.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Coding Problem - Too few parameters
    By JJPetersen1 in forum Programming
    Replies: 2
    Last Post: 08-16-2023, 10:32 AM
  2. Replies: 19
    Last Post: 04-12-2020, 12:51 PM
  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