Hi John,
Yes! I have applied your code and is working, i don't need to display a message.
Thank you very much.
Regards,
Khalid
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Khalid-
Hi John,
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Use On Error Resume Next if it's likely your code will trigger an error, but you don't care about just ignoring it. If you're happy leaving the rate 0 if the DLookup fails, then use that. Note that you can still check for Err <> 0 right after a statement that might fail to see if an error was triggered but ignored.
As for the code I suggested to avoid any error, you could do something like a MsgBox to the user to let them know that you're unable to set the rate for them, then simply Exit Sub.
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 Apr 10, 2017, at 1:04 AM, khalidtanweerburrah@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Hi John,
Thanks for answering.
Actually my question was simply to know that my code is working and giving me no error on getting Focus to the control "Rate", whether it is correct or there is some other method or way to define the code, particularly the line:
==> On Error Resume Next
The event is as follows:
Private Sub Rate_GotFocus()
On Error Resume Next
If IsNull(WeightOfCarton) Then
MsgBox "Oops you forget to enter Weight Of Carton." & vbCrLf & _
"Please enter Gross Weight." _
, vbExclamation, "Missing Entry"
WeightOfCarton.SetFocus
End If
Dim varRate As Double
varRate = DLookup("DestinationRate", "tblDestinationRates", _
"Destination = '" & Me.cmbDestination & _
"' AND ProductID = " & Me.ProductID & "")
Me.Rate = Nz(varRate, 0)
End Sub
I did tried with the code you suggested to see the results, but i'm sorry i don't know what should be written On Error Statement ?
Also please see first para of my this reply, i needed answer for that. Even if you suggest to use your code then please tell me what should be the On Error statement. Sorry for my limited knowledge.
Regards,
Khalid
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Khalid-
You can test for empty entries like this (right after the On Error statement):
If (Len(Me.cmbDestination & "") = 0) Or (Len(Me.ProductID & "") = 0 Then
' Take alternative action - don't try to lookup the rate
Else
varRate = DLookup( ….
Me.Rate = NZ(varRate, 0)
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 Apr 9, 2017, at 7:02 PM, khalidtanweerburrah@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
__._,_.___
Posted by: khalidtanweerburrah@yahoo.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (10) |
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