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
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
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
nothing appears and there is no code for the castcode control
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 error1. 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
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.
think about it - you original code referenced column 1, now you are referencing column 0
Your problem was the hello msgbox not showing- are you saying it still isn’t showing?
Yes it is not showing
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
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.
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.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:
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.