SetFocus to ComboBox

  • Thread starter Thread starter Clau
  • Start date Start date
C

Clau

Hi there, I am new to access programming and I need to use the setfocus
on a ComboBox on a form, as I have never done that I am completely
lost... here is the thing:

I have a form (loan) where I have a ComboBox (BookCode) and in that
combobox I´ve created the following event:

Option Explicit
Option Compare Database

Private Sub BookCode_BeforeUpdate(Cancel As Integer)
If Status = "Lent" Then
MsgBox "The book is not available"
End If
End Sub

so far it works, but I need to add a setfocus to fix the mouse pointer
to the ComboBox and I have no clue on how to continue...

Can anyone help ???
 
Me.BookCode.SetFocus


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi there, I am new to access programming and I need to use the setfocus
on a ComboBox on a form, as I have never done that I am completely
lost... here is the thing:

I have a form (loan) where I have a ComboBox (BookCode) and in that
combobox I´ve created the following event:

Option Explicit
Option Compare Database

Private Sub BookCode_BeforeUpdate(Cancel As Integer)
If Status = "Lent" Then
MsgBox "The book is not available"
End If
End Sub

so far it works, but I need to add a setfocus to fix the mouse pointer
to the ComboBox and I have no clue on how to continue...

Can anyone help ???
 
Thanks, I wrote it like this...

Private Sub BookCode_BeforeUpdate(Cancel As Integer)
If Status = "Lent" Then
MsgBox "The book is not available"
Me.BookCode.SetFocus
End If

But it didn´t work, what am I doing wrong ??
 
Syntactically, your code looks correct. What's not happening that you expect
to have happen?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Thanks, I wrote it like this...

Private Sub BookCode_BeforeUpdate(Cancel As Integer)
If Status = "Lent" Then
MsgBox "The book is not available"
Me.BookCode.SetFocus
End If

But it didn´t work, what am I doing wrong ??
 
Back
Top