Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Member
 
Join Date: Apr 2007
Location: somewhere in your neighborhood
Posts: 52
#1: May 3 '07
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

Member
 
Join Date: Apr 2007
Location: somewhere in your neighborhood
Posts: 52
#2: May 3 '07

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


please tell me whats wrong with this code,,, vb highlights Cancel+false ang gives error message that variable is not defined
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,748
#3: May 3 '07

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


This is NOT an article.
I'm moving this to the main Access questions forum.

MODERATOR.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,748
#4: May 3 '07

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


Quote:

Originally Posted by rockdc1981

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.
JConsulting's Avatar
Expert
 
Join Date: Apr 2007
Location: Houston
Posts: 601
#5: May 6 '07

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


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
Reply