Modules & VBA :: Class Event For Multiple Controls On Userform
Mar 5, 2014
Basically I have a class event that works for all controls on any userform.
Its all working fine but I can't add an event to trap the click or mouse move of the userform itself.
Basically so when the cursor moves away from a control the label clears.
User Form Code
Code:
Option Compare Database
Option Explicit
'Define a collection and initialise the commandbutton event class
Private col As New Collection
Private newCmd As New clsEvents
[Code] .....
And here is the class Module
Code:
Option Compare Database
Option Explicit
'catch the event of Commandbuttons
Private WithEvents C0 As SubForm
'Private WithEvents C1 As CheckBox
[Code] ....
View Replies
ADVERTISEMENT
Aug 7, 2013
I am trying to set event handlers on multiple controls in code. This works:
Code:
Me.Controls("txtPosition" & Right(CStr(iLoop + 100), 2)).OnClick = "=UpdateTaskList(" & CStr(iLoop) & ")"
This doesn't:
Code:
Me.Controls("txtPostIt" & Right(CStr(iLoop + 100), 2)).OnGotFocus = "=PostItGotFocusHandler2()"
The second gives an error: "The expression you entered has a function that <databasename> can't find.
I suspect it may be a parameter mismatch, but the normal GotFocus event handler does not take any parameters.
View 2 Replies
View Related
Jan 10, 2006
i have 15 text boxes named Qty1, Qty, Qty3, etc...
and another 15 text boxes named Comment1, Comment2, Comment3, etc...
i'd like to write an AfterUpdate event code that will apply to all of the Qty controls..instead of write 15 individual AfterUpdate events..
is this possible at all?!
View 6 Replies
View Related
Nov 29, 2013
I'm using a mousemove event to display help text for controls in my form.This works well, but I'd like to display help text when the control is disabled as well (to explain to the user why it's disabled).is there any way to fire a mousemove event when hovering over a disabled control?
View 1 Replies
View Related
Jul 24, 2013
I have a report that tracks scores for our employees. From the report, you can click a button to add a new score in a form or edit an existing score(frmscoretracker). On this form there are two subforms, in a tabbed control to track additional information about the score; what areas were marked down(Trends), and was it a failing score(AutoFail).
When this form opens I have it programmed to only show the subform if there is data in it. The goal being, if I am adding a new score and there is no existing trends or Autofails for this new record, neither subforms will show - I will add an after update even to show either trends or autofail depending on the score recorded. Also, if someone chooses to edit the score, whatever subform with data, will show as well.
When someone clicks to add a new score, opening this main form to a new record, both of the tabs show. However, if the form opens to an existing record, the appropriate tab shows. Here is the code
Code:
Private Sub Form_Open(Cancel As Integer)
'If the subform has a record, the tab is visible, if not, the tab is not visible
If Me.frmtrends.Form.Recordset.RecordCount > 0 Or IsNull(Me.Trends) Then
Me.Trends.Visible = True
Me.TabCtl33.Visible = True
Else
Me.Trends.Visible = False
End If
[code]...
Both tabs are set as not visible in the default settings. Is there something in this code that is triggering then to be visible when there is no record in the main form?
View 4 Replies
View Related
Aug 13, 2015
There are 4 unbound dropdown list box that will have a default value of empty string. All 4 must have values entered (data is required).Once all 4 are required - the bottom 5 text box will become enabled (optional data).Forcing the user to click on a Validation Button
Some users type then use the mouse to select the next.Other users type to select then tab.The trick is: After filling in the 4th listbox and validating all 4 have values, the event must trigger code to enable the 5 optional text boxes below.This provides a seamless data entry environment.
I have been doing this in other places, but the transisition after the last required field is complete gets ugly.If Trim(cmbBoxname1 & "") = vbNullString ' check all 4..If it is the 4th one, the event seems not to happen quick enough for the bottom 5 text boxes to be enabled so the user can continue with data entry.
View 9 Replies
View Related
Jul 31, 2014
I work for a company that manufactures home appliances & electronics. When those products fail within the warranty period, we are obligated to repair the units for the customers.
We have around 200 factory technicians who make those repairs. Each tech is able to make approximately 8 repairs each day. We have a dispatching system that assigns the repairs to the techs based on their availability each day. But the problem is that we have to manually enter and adjust the schedule for all 200 techs every single day, and this takes a lot of time. And of course technicians get sick, take vacation, etc, so we have to adjust the schedule so no techs will be assigned calls when they're off.
The problem: For example, currently when a technician takes off for 2 weeks, the user has to enter 14 individual records for the tech, which is somewhat time consuming. What I need is to program a button click event to determine the two dates (startDate & endDate) and append multiple records from one single entry in the form for each date in between and including the two date fields.
I know I'll probably need to create a loop that will loop through the two dates on the form and append a record for each day, so I can then cross reference the dates to the master schedule dates to make sure that no availability is opened for the techs taking time off.
View 3 Replies
View Related
Jul 31, 2015
I get the message "The expression On Click you entered as the event property setting produced the following error: Class does not support Automation or does not support expected interface"
I receive the message on a PC running Windows 7 Professional using the Access 2013 Runtime. This pc does not have Access 2013 installed.On my pc, I do not get the error. I have Access 2013 installed and run Windows 7 Professional SP1. The "code" which gives the error is as follows and is invoked by clicking a button on a form
Code:
MsgBox "1"
Dim rst As ADODB.Recordset
MsgBox "2"
Set rst = New ADODB.Recordset
MsgBox "3"
[code]....
The error takes place after Msgbox "2" and before Msgbox "3".The strange thing is that I can run without a problem a sophisticated software package on the pc which gives the error, using Access 2013 Runtime. This package I converted from Access 2003.
View 3 Replies
View Related
May 23, 2014
I am new to access and am a bit stuck. I have a userform i want to populate once a reference number has been entered into a unbound textbox. How to create a macro that will pull the data out of my database?
View 10 Replies
View Related
Mar 19, 2014
I have this below which some people cant run and some people can. All are using 2010 runtime version. Apart from the one guy who can run the macro who has full 2010 version. I have 2010 runtime installed and i can also run the macro fine.
Private Sub Option12_Click()
On Error GoTo Option12_Click_err
Dim CntlPay As String
Dim Lable As String
CntlPay = "D"
[code]....
View 1 Replies
View Related
Sep 16, 2013
How you automatically initialize a newly instantiated class?
So when you create a new instance it will run a procedure to set attributes.
View 4 Replies
View Related
Oct 21, 2013
I have wrote a database in access 2010 and the database works fine for me (I am the db admin with full control).I gave the database to a group in which most of them also have no issue with the file. They are able to use the database with no issues..One of those members gets an error message when completing the initial step in the database: (select a drop down item from a combo box)
Code:
The expression After Update you entered as the event propoerty setting produced the following error: Object or class does not support the set of events
Something I cant seem to understand is why is this happoening on 5 machines but not on the 6th, they all have the same PC set up so there should be no error on one particular machine.
View 6 Replies
View Related
May 19, 2014
I have two class variables (both arrays) among about 10 other class variables, that are not returning any values but "" for the string or #12:00:00AM" for a date. Here are my class variables:
Code:
'UPSData Class Module
Private p_LetterArray() As String
Private p_date() As Date
Private p_LetterArraySize As Integer
My Properties
Code:
'Properties
Public Property Get LetterArray(index As Integer) As String
LetterArray(index) = p_LetterArray(index)
End Property
Public Property Let LetterArray(index As Integer, NewValue As String)
[Code] ....
As I said, tLet and tDate result in "" and #12:00:00AM# respectively. When I step through the code, the values for tmp.LetterArray(0) is assigned "src" and tmp.UPSDate(0) stores "12/25/2013" correctly.
When I assign tLet and TDate, the same thing happens when stepping through the code. I'll use the LetterArray property to describe what happens:
Get LetterArray is called. p_LetterArray(0) does equal "src"
Let LetterArray is called. NewValue is "src" and p_LetterArray is "src" when End Property is highlighted in the debugger
Scope returns to Get LetterArray with End Property highlighted. In checking the values, LetterArray(0) = ""
Same steps happen with the same results ("12:00:00AM" vice "")
View 5 Replies
View Related
Jul 31, 2013
Any way to make objects to support adjusting continuous form controls making them unique in a sense to be able to change info like captions or whatever.
I've been working with collections for a while now tapping into event handlers such as the mouse inputs and or sizing of objects real time using collections but I can't seem to nail down any un-documented way to serialize controls on a continuos form.
I have tried when the new user creates the record adding another control to the collections class tying it to the id of the record but still this does not seem to be enough.
I do not know if there is a paint method or something of the sort I can override to get the desired results and most people without even trying will tell you this can't be done but how many have said that you can't move and resize objects in access but we are doing that now...
View 14 Replies
View Related
Jun 26, 2015
I'm using Access 2003. In "References" (Tools > References > Browse...), I've added in "Microsoft Windows Common Controls 6.0 (SP6)" (c:windowssystem32mscomctl.ocx).
I've then created/inserted an instance of the control "Microsoft ListView Control 6.0 (SP6)" on a Form ("MyForm") and given the listvew control the Name "MyListView".I wanted to decorate MyListView with some custom methods so I've created a new class module ("DecoratedListView") which contains a member field called "lvw".
I want 'lvw' to point/reference to MyListView, but I don't know what reference type to use in its declaration. Importantly, I also want to capture lvw's ColumnClick event.
I've tried:
Code:
Public WithEvents lvw As Object
Public WithEvents lvw As Control
Public WithEvents lvw As MSComctlLib.ListView.2
Public WithEvents lvw As MSComctlLib.ListView
Public WithEvents lvw As CustomControl
and none works when I
Code:
set lvw = Forms!MyForm.MyListView
The first try (Object) doesn't even compile. I get the exception "Expected: identifier"
The second try (Control) doesn't compile either. I get the exception "Object does not source automation events"
The third try (MSComctlLib.ListView.2) doesn't compile and throws the exception "Expected: end of statement"
The fourth try (MSComctlLib.ListView) compiles but fails at runtime with the exception "Type mismatch". Using TYPENAME() on the control returns "CustomControl".
The fifth try (CustomControl) compiles but fails at runtime with the exception "Object or class does not support the set of events".
I can't believe I'm the first person to have tried to capture an ActiveX Control's events in a separate class.
View 1 Replies
View Related
Jun 13, 2013
I've been playing around with creating my own class in VBA but I'm having problems calling its methods. My class is pretty basic, its called cDentist and the properties are just Name, Address, DOB etc and one method AddDentist. AddDentist will add the details to a sql server table.
So I create an instance of the class in a module called Dentist. At the very top of the code i put..
Code:
Option Compare Database
Global Dentist As cDentist
I have a method then in module Dentist, where I initialise the instance of class cDentist and i populate it's properities...
Code:
Sub RecordDentistDetails()
Set Dentist = New cDentist
Dentist.Name = Forms!frm_enterdetails!txtName
[Code].....
When I click 'Save' I get error, Method or data member not found. And '.AddDentist' is highlighted. I'm a little confused why it's not seeing AddDentist as a method of class cDentist.
View 14 Replies
View Related
Jan 30, 2014
I am trying to pass a boolean variable to a class module
Code:
Set rps.ViewS = View
the code in the module that this in theory is calling reads as
Code:
Private ViewC As Boolean
Public Property Set ViewS(ByRef ViewA As Boolean)
Set ViewC = ViewA
End Property
Public Property Get ViewS() As Boolean
Set ViewS = ViewC
End Property
However I am getting the error message
Quote:Definitions of property procedures for the same property are inconsistent, or property procedure has an optional parameter, a ParamArray, or an invalid Set final parameter.
View 6 Replies
View Related
Jun 10, 2014
I haven't created classes in a while, and I don't see what is the problem
I'm modifying a function to get fractions from double. It worked well, but it returned a string.
I need it to be in parts, so I created this class
Code:
Option Compare Database
Public Entier As Integer
Public nominateur As Integer
Public denominateur As Integer
Public Function getText()
getText = Entier & " " & nominateur & "/" & denominateur
End Function
I changed the function type and the assignation:
Code:
Function GetFraction(ByVal Num As Double) As nombreEnFraction
Set GetFraction = New nombreEnFraction
If Num = 0# Then
GetFraction = "None"
Else
Dim WholeNumber As Integer
Dim DecimalNumber As Double
[Code] ....
For some reasons, when I get to the end of the function, I get a 91 error, like if it was nothing
But when I use a spy, I see values in the object until the end.
View 1 Replies
View Related
Mar 30, 2015
I have a parent form which has a class variable (class module instance) to store the form' status and more.... and when i add a new record to the subform it resets the class variable field' data. but this only happens on first transaction, but if i re-run the steps (re-set the variable field value) it's not happening again.
View 3 Replies
View Related
Jun 6, 2014
I'm trying to subtotal data in an excel file but I am getting a subtotal method of Range class failed in the red text below. I have been trying to get this to work with no success.
Code:
Public Function SUMMARY()
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
With xlApp
Dim wb As Object
[Code] .....
View 3 Replies
View Related
Jul 14, 2006
Hello,
I have a form with multiple controls (textboxes) named:
Father
Mother
Child1
Child2
On the form there are also two checkboxes (check1 and check2).
I am using the following statement for each control and placed in in the OnCurrent event of my form:
If Not IsNull (Me.Fater) Then
Me.Check1 = "YES" (or -1)
Me.Check2.Value = False
End IF
Is there a way I can write one If statement saying:
If all controls Father, Mather, Child1 and Child2 or at least one of them has data, then Check1 should be selected and check2 emply. If all controls do not have data then ckeck1 should be empty and check2 selected.
Thank you.
View 2 Replies
View Related
Jan 22, 2007
Hello, I am reposting a question submitted some time ago to which I did not get much help, hoping for additional advice.
My database has two tables. Table1 and Table2. Table2 is a copy of Table1. Both tables have 50 fields. Data is imported into Table1 once a week. Before importing data I run a delete query which removes all data. Data imported adds records only to the following fields: FNAME, LNAME, SSN. This means that I am left with 47 empty fields.
Users can see data in Table1 using Form1. They will see the FNAME, LNAME and SSN. These fields are locked and cannot be edit or deleted. All the other 47 fields are blank and user can add data to them.
Currently I am using two buttons to:
1) Close the form (with the code Me.Undo, Me. CLose)
2) Run and append query to Table2 and deleting all added data.
I would like to combine these two functions in one button which would:
If no data has been entered in the remaining 40 fields, than close the form.
If data has been entered it should run the following procedure (Append data into Table2):
Dim MyDb As DAO.Database, MyRs As DAO.Recordset
Dim strCode As String
Dim strFilter As String
Dim stDocName As String
Dim stLinkCriteria As String
Set MyDb = CurrentDb
Set MyRs = MyDb.OpenRecordset("Table1")
stDocName = "MyForm"
stLinkCriteria = "[SSN]=" & "'" & Me![SSN] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.SetWarnings False
DoCmd.OpenQuery ("AppendtoTable2")
DoCmd.Close
The problem I am having is declaring all the 47 empty records. Any suggestion or code? Thanks.
View 1 Replies
View Related
Aug 11, 2014
I've constructed a trivia database that consists of trivia questions that are classified into different categories. The DB also keeps track of which questions were used at which establishment. I am designing a form that will generate multiple rounds of trivia based on user criteria.
As seen here the user can specify the number of rounds and questions per round. Maximum number of rounds is 8 - the tab visibility is changed AfterUpdate of the number of rounds field.I have queries set up that do what I need for a single round - they choose random questions based on category, subcategory, difficulty and if they haven't been used at that client's before.
how to deal with multiple rounds without it becoming a headache. My tab layout has controls txtCategory1, txtSubCategory1, txtDifficulty1, txtType1, txtCategory2, and so on. Currently the queries use the values in the controls for Round 1. I would have to make eight copies of these queries (one copy for each round) in order to generate each round based on specific criteria, which would make a ton of queries. The other option is to use SQL statements in VBA, but this method doesn't like the [Forms]![frmCreateTriviaNight]![cboCategory1] in the code - I have to concatenate the names of the variables in and the code would be a mess.
View 2 Replies
View Related
Aug 8, 2007
Hello,
I have two controls on my form that I want to reference in an append query to create a new record. The first is a text box, the second is a combobox that is populated with all of the dates associated with the text box. The selection of a date updates a subform based off of a hidden column (chart ID, an autonumber field based on combinations of record numbers and visit dates) in the same combobox.
I would like the user to be able to enter a new date and create a new record that would contain the next autonumber in association with the new date and the record number from the text box control. I have tried using an append query with the following SQL, but I consistently get errors referring to "type mismatch." Any help would be greatly appreciated; thanks in advance.
Code:Private Sub cboDOVSearchChart_NotInList(NewData As String, Response AsInteger)Dim ans As Variantans = MsgBox("The date you entered was not found. Do you want to add a newdate?", _vbYesNo, "Add New Date?")If ans = vbNo ThenResponse = acDataErrContinueMe.cboDOVSearchChart = NullDoCmd.GoToControl "cboDOVSearchChart"GoTo exit_itEnd If' add dateIf ans = vbYes Then Dim strSQL As String strSQL = "INSERT INTO Patient_Visits ([Medical Record Number], " _ & "[Date of Visit]) " _ & "Values (" & Me.[txtChartMR] & ", " _ & "#" & CDate(NewData) & "#)" 'this line has the arrow on debug CurrentDb.Execute strSQL Me.cboDOVSearchChart.Requery Me.cboDOVSearchChart = NewData Call cboDOVSearchChart_AfterUpdateEnd Ifexit_it:End Sub
View 2 Replies
View Related
Feb 26, 2014
On the form I need to give the user the option to select a 'from date' and 'to date' and for this I have put in 2 calender controls which have the same control source(same table column). The problem I am facing is when I select a date from one calendar, the other calendar control automatically populates with the same date and vice versa.
I need to have a functionality where 2 different date can be selected and then when the Search button is clicked, then data within the date ranges should be displayed.
what changes I need to make to acomplish this ? find a screenshot of the form attached.
View 5 Replies
View Related
Nov 14, 2012
My form-based search mechanism uses controls to set the parameters for the query data source.
I have one field call quantity in stock. I could you a Between and And method to allow the end user to input the stock quantity they want.
HOWEVER, i would love it for the user to first select the Comparison Operator (e.g. > , <, >=, <=) from a combo box and then in an adjacent text box, enter the quantity.
The expression i entered in the query goes something like this.... Forms![frmSearch]![cboRange] & [Forms]![frmSearch]![txtQuantity]
When i try and run this, i get the message "THe expression is too complex to be evaluated".
View 5 Replies
View Related