473,324 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

variable not defined(on lost focus to a combo box, prompt message)

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo42_LostFocus()
  2. ' Display message if Combo38 is blank.
  3.     Dim strMsg As String, strTitle As String
  4.     Dim intStyle As Integer
  5.     If IsNull(Me!Combo73) Or Me!Combo42 = "" Then
  6.         strMsg = "You Must Add or Select Record."
  7.         strTitle = "Select or Add Record"
  8.         intStyle = vbOKOnly
  9.         MsgBox strMsg, intStyle, strTitle
  10.     Cancel = True
  11.     End If
  12. End Sub
May 3 '07 #1
4 2679
please tell me whats wrong with this code,,, vb highlights Cancel+false ang gives error message that variable is not defined
May 3 '07 #2
NeoPa
32,556 Expert Mod 16PB
This is NOT an article.
I'm moving this to the main Access questions forum.

MODERATOR.
May 3 '07 #3
NeoPa
32,556 Expert Mod 16PB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo42_LostFocus()
  2. ' Display message if Combo38 is blank.
  3.     Dim strMsg As String, strTitle As String
  4.     Dim intStyle As Integer
  5.     If IsNull(Me!Combo73) Or Me!Combo42 = "" Then
  6.         strMsg = "You Must Add or Select Record."
  7.         strTitle = "Select or Add Record"
  8.         intStyle = vbOKOnly
  9.         MsgBox strMsg, intStyle, strTitle
  10.     Cancel = True
  11.     End If
  12. End Sub
This code must have been taken from an event procedure (like a _BeforeUpdate()) which has the ability to cancel. The _LostFocus() event procedure doesn't have that ability so doesn't define a Cancel parameter. You refer to a non-existent parameter.
May 3 '07 #4
JConsulting
603 Expert 512MB
replace your Cancel = true with

me.mycombobox.setfocus.

this will return the user to the combo box so that a value can be selected.
J
May 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: fortepianissimo | last post by:
We all know that using __getattr__() we can compute an instance variable on demand, for example: class Foo: def __getattr__ (self, name): if name == 'bar': self.bar = 'apple' return self.bar...
2
by: Charles | last post by:
I need to retreive a URL variable on a .asp page using either ASP or JS and then put in into the URL of an img tag. Example: - The page we are looking at has URL...
1
by: Danny Poulsen | last post by:
Hi How do I transfer a variable on one page to another page? example: page1.htm <script language="JavaScript"> var t = 1; </script>
3
by: Steve | last post by:
Is there a way to get the type information for the class an attribute is defined on at runtime? I tried getting the attribute type, and then checking the DeclaringType property but it was null. ...
3
by: Tor Inge Rislaa | last post by:
How to refer to a variable on another webform Hi, I have a Webform1 with a public variable that is assigned a value before my Webform2 is displayed. In the Page_Load procedure of Webform2 I want...
5
by: brett | last post by:
I'd like to display a string variable on a webpage depending if the URL has "localhost" in it or not. The string variable will have line breaks and this text: <script type="text/javascript"...
0
by: Joao Batista | last post by:
Hi all, When i run this code, it raises a error, DataList1.DataSource = pagedData ------> ... Error ..... DataList1.DataBind() Error: Both DataSource and DataSourceID are defined on...
1
by: db2udbgirl | last post by:
Env : DB2 UDB 8.2 / AIX 5.3 When I try to use some DB2 Utilities against a partitioned table which is not defined on a particular node (Node 0 in this case) I'm getting this error. ...
5
by: dmorand | last post by:
I'm assuming I can't pass a javascript variable to a cf variable on the same page because js is client and cf is server correct? I've got a drop down list which I want it to populate a form on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.