A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

".SetFocus" on a form element and then having the combo box ".Dropdown"



 
 
Thread Tools Display Modes
  #1  
Old January 14th, 2007, 09:22 PM posted to microsoft.public.access.formscoding,microsoft.public.access.forms
CES
external usenet poster
 
Posts: 25
Default ".SetFocus" on a form element and then having the combo box ".Dropdown"

All,
I can't seem to get ".SetFocus" and ".Dropdown" to play nicely with one another.
I have a general function that Enables/Disables a Form Field. Which is called using the onExit Event Property (I've tried Lost Focus,Got Focus Events as well and that causes the same problem), of the Field Element.
The problem that I am running into is that I can't call the function prior to leaving the field because if I do,it will throw an error. So I need to SetFocus to the another field, prior to calling the function.
However, when I do that the dropDown property ceases to work properly, it drops down for a brief moment and then rolls back out.
If anyone has a clue as to how to get this to work properly, I would appreciate any advice or guidance. Thanks in advance.- CES

Fields list in Tab Order:
' ClientId - Combo
' DateOfInvoice - This field has been Disabled and Locked
' ApplyTo - Combo

Public Function fnEnableDisableTxtBox(controlName As String, actionToTake As String)
' Call fnEnableDisableTxtBox("NameOfTextBox", "Disable or Null")
' Will Change to opposite of Current State

Dim tmp As Control

Set tmp = Me.Controls(controlName)

If actionToTake "Disable" Then
tmp.Enabled = True
tmp.Locked = False
tmp.BackStyle = 1
Else
tmp.Enabled = False
tmp.Locked = True
tmp.BackStyle = 0
End If

End Function


Private Sub ClientId_Exit(Cancel As Integer)
If Me.DateOfInvoice.Value "" Then

'Me.DateOfInvoice.SetFocus - Will throw an error because it's already been Locked & Disabled
'Me.ApplyTo.Dropdown - Will throw an error, most likely because it doesn't have focus yet
'Me.ApplyTo.SetFocus - Will not throw an error, however the menu doesn't drop down properly
' it will only drop down for a brief moment and then it roll back up.
'Me.ApplyTo.Dropdown - Will not throw an error,

Call fnEnableDisableTxtBox("ClientId", "Disable")
End If
End Sub


Private Sub ApplyTo_Enter()
Me.ApplyTo.Dropdown
End Sub
  #2  
Old January 14th, 2007, 09:32 PM posted to microsoft.public.access.formscoding,microsoft.public.access.forms
CES
external usenet poster
 
Posts: 25
Default ".SetFocus" on a form element and then having the combo box ".Dropdown"

CES wrote:
All,
I can't seem to get ".SetFocus" and ".Dropdown" to play nicely with one
another.
I have a general function that Enables/Disables a Form Field. Which is
called using the onExit Event Property (I've tried Lost Focus,Got Focus
Events as well and that causes the same problem), of the Field Element.
The problem that I am running into is that I can't call the function
prior to leaving the field because if I do,it will throw an error. So I
need to SetFocus to the another field, prior to calling the function.
However, when I do that the dropDown property ceases to work properly,
it drops down for a brief moment and then rolls back out.
If anyone has a clue as to how to get this to work properly, I would
appreciate any advice or guidance. Thanks in advance.- CES

Fields list in Tab Order:
' ClientId - Combo
' DateOfInvoice - This field has been Disabled and Locked
' ApplyTo - Combo

Public Function fnEnableDisableTxtBox(controlName As String,
actionToTake As String)
' Call fnEnableDisableTxtBox("NameOfTextBox", "Disable or Null")
' Will Change to opposite of Current State

Dim tmp As Control

Set tmp = Me.Controls(controlName)

If actionToTake "Disable" Then
tmp.Enabled = True
tmp.Locked = False
tmp.BackStyle = 1
Else
tmp.Enabled = False
tmp.Locked = True
tmp.BackStyle = 0
End If

End Function


Private Sub ClientId_Exit(Cancel As Integer)
If Me.DateOfInvoice.Value "" Then

'Me.DateOfInvoice.SetFocus - Will throw an error because it's
already been Locked & Disabled
'Me.ApplyTo.Dropdown - Will throw an error, most likely because it
doesn't have focus yet
'Me.ApplyTo.SetFocus - Will not throw an error, however the menu
doesn't drop down properly
' it will only drop down for a brief moment and then it
roll back up.
'Me.ApplyTo.Dropdown - Will not throw an error,

Call fnEnableDisableTxtBox("ClientId", "Disable")
End If
End Sub


Private Sub ApplyTo_Enter()
Me.ApplyTo.Dropdown
End Sub


All,
Sorry for the premature post... SetFocus Was not causing the problem as I had thought, the problem was generated by one of the next two lines of code. Somehow they were drawing focus away from appliedTo.
changing the code as follows solved the problem. - CES

Private Sub ClientId_Exit(Cancel As Integer)
If Me.DateOfInvoice.Value "" Then
Me.ApplyTo.SetFocus
Me.InvoiceID.Value = fnSetInvoiceID(Me.ClientId.Value, Me.DateOfInvoice.Value)
Call fnEnableDisableTxtBox("ClientId", "Disable")
Me.ApplyTo.Dropdown

End If
End Sub
  #3  
Old January 14th, 2007, 11:21 PM posted to microsoft.public.access.formscoding,microsoft.public.access.forms
CES
external usenet poster
 
Posts: 25
Default ".SetFocus" on a form element and then having the combo box ".Dropdown"

CES wrote:
CES wrote:
All,
I can't seem to get ".SetFocus" and ".Dropdown" to play nicely with
one another.
I have a general function that Enables/Disables a Form Field. Which is
called using the onExit Event Property (I've tried Lost Focus,Got
Focus Events as well and that causes the same problem), of the Field
Element.
The problem that I am running into is that I can't call the function
prior to leaving the field because if I do,it will throw an error. So
I need to SetFocus to the another field, prior to calling the function.
However, when I do that the dropDown property ceases to work properly,
it drops down for a brief moment and then rolls back out.
If anyone has a clue as to how to get this to work properly, I would
appreciate any advice or guidance. Thanks in advance.- CES

Fields list in Tab Order:
' ClientId - Combo
' DateOfInvoice - This field has been Disabled and Locked
' ApplyTo - Combo

Public Function fnEnableDisableTxtBox(controlName As String,
actionToTake As String)
' Call fnEnableDisableTxtBox("NameOfTextBox", "Disable or Null")
' Will Change to opposite of Current State

Dim tmp As Control

Set tmp = Me.Controls(controlName)

If actionToTake "Disable" Then
tmp.Enabled = True
tmp.Locked = False
tmp.BackStyle = 1
Else
tmp.Enabled = False
tmp.Locked = True
tmp.BackStyle = 0
End If

End Function


Private Sub ClientId_Exit(Cancel As Integer)
If Me.DateOfInvoice.Value "" Then

'Me.DateOfInvoice.SetFocus - Will throw an error because it's
already been Locked & Disabled
'Me.ApplyTo.Dropdown - Will throw an error, most likely because it
doesn't have focus yet
'Me.ApplyTo.SetFocus - Will not throw an error, however the menu
doesn't drop down properly
' it will only drop down for a brief moment and then
it roll back up.
'Me.ApplyTo.Dropdown - Will not throw an error,
Call fnEnableDisableTxtBox("ClientId", "Disable")
End If
End Sub


Private Sub ApplyTo_Enter()
Me.ApplyTo.Dropdown
End Sub


All,
Sorry for the premature post... SetFocus Was not causing the problem as
I had thought, the problem was generated by one of the next two lines of
code. Somehow they were drawing focus away from appliedTo.
changing the code as follows solved the problem. - CES

Private Sub ClientId_Exit(Cancel As Integer)
If Me.DateOfInvoice.Value "" Then
Me.ApplyTo.SetFocus
Me.InvoiceID.Value = fnSetInvoiceID(Me.ClientId.Value,
Me.DateOfInvoice.Value)
Call fnEnableDisableTxtBox("ClientId", "Disable")
Me.ApplyTo.Dropdown

End If
End Sub


Please reply to a newer posting (Still not working - ".SetFocus" on a form element and then having the combo box ".Dropdown")
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:57 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.