Modules & VBA :: Class Variable Resets When Adding New Record In Subform
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.
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.
I am currently working on an Access Database that houses our security clearance information. Most of the system is up and running but the most recent form has got me spinning my wheels. I have a Word User Form that users will download and complete, once completed the macros will automatically send us the document to be added to our database. Most of this is working the problem is that this portion of the database has multiple related tables and at any given time a user may require multiple records in the related tables. I have created the code to copy most of the information but am getting stuck adding a new record on the sub-form when multiple items are required. Here is a breakdown of the scenario
Word Doc Table 1 = Basic Organization Info Word Doc Table 2+ = Sites to Visit (There could be more than 1 table added here) Word Doc Table 3+ = People to go on site (this might not be the third table based on user interaction for sites)
So far I can get Table 1 and Table 2 data but if there are more than 1 site I cant seem to get the system to create a new record on the related table it is creating a new record on the main form. Here are the lines I used to try to create the related record..
When I put just the above code on a button it seems to have worked as the sub-form showed an additional record was created but when using this on my macro the sub-form is not taking the focus for some reason.
I'm creating an attendance tracking system, the attendance system needs to : Allow an instructor to enroll students into one or more classes, and then add attendance by date to each class(es). The problem that I'm having is, attendance is tracked by the number of hours that a student attends class. For instance, if class1 is in session from 8a.m. - 12p.m. student1 may only stay 2.50 hours of that class and student2 may stay 3 hours. The teacher needs to be able to add attendance to class1 for July 12, 2013 and add hours for each student enrolled in this class session who attended on that day. I have the following so far, minus the attendance:
Students -This is just the basic demographic information that instructors will need to enter on students. StudentID (PK) StudentLastName StudentFirstName DateOfEnrollment LevelOfStudy DateOfBirth
Location - These are the locations in which our students can attend classes LocationID (PK) LocationName County City LocationPhoneNumber LocationFaxNumber
Classes - These are the classes that our students can attend. CRNNo (PK) ClassName LocationID InstructorID
Instructor - These are the instructors that teach our classes. InstructorID (PK) InstructorLastName InstructorFirstName InstructorEmailAddress
Enrollment - This table enrolls the student into a class StudentID(PK) CRNNo (PK) LocationID (PK)
I am creating a 2 level report to confirm an order. Main report already created, runs successfully called as subform/subreport under "OrderDetails" form. Linked to master using Order.ID. There are two versions of the confirmation report that have different layouts for different program types.
The hangup comes when I try to add a "Class Dates" subreport. It lists dates of individual classes and Skip dates. I have created the subreport as "srClassDates". When I add it to the main report, it lists the records. However, when I try to link it to the Main report, an error message box appears with the "object variable or With block variable not set".
I have tried rebuilding both the main and subreports, rebuilt the query, have not found anything that changes the result.
Linker has been working successfully on other subforms. Report with groupings works fine, but I need data from 2 tables both linked to order.id.
I have inherited a partially completed membership Access database which I understand was originally generated from a load of linked FoxPro tables. There is a form which uses multiple tabs, the first tab contains general membership data (ie name, age etc) and this pulls data through from the 'Main' table in the database. Each of the other tabs includes a subform which shows data held in a number of different tables linked to the 'Main' table (eg, first tab - general data from 'Main table', 2nd tab - home addreses from 'Home Address' table, 3rd tab - business addresses from 'Business Address' table). All tables are linked to the 'Main' table through a common 'RegisterID' field. When I open the form I can query on any of the records and amend and items of data on the various tabs them without any problem. However if I add a new record using the >* option from the record navigation I can add data to the first tab (ie. into the 'Main' table) but if I move to the 2nd or 3rd tab I am unable to edit/add data to the fields on those tabs. But if I save the record after completing the fields on the first tab and then close the form and reopen it I can then edit the 2nd and 3rd tabs, can you suggest how I can change the setup to allow editing/adding data to the 2nd and 3rd tabs without having to close the form and reopen it please. I have checked the subforms and they are set to AllowEdit and there are NoLocks.
I have a form with a subform (in continuous) I have on the main form a few unbound text boxes which once im happy with the results i press a command button on mainform which adds the unbound text boxes to a new record on subform im struggling with this one. I have done similar before but that was with the unbound text boxes in header of the actual form i was adding record too.
Hey everyone, This seems like a great community for access - I'm glad I stumbled across here because I have some issues that need figured out.
I've searched the forum for answers and I have found a few posts with suggestions, but nothing has worked yet. (by the way, I'm fairly new to access, but not to databases in general).
So here's my problem, and I appreciate any help in advance.
- I have a main form and 2 subforms on the main form. The main form contains the information of thousands of Titles to different sections of land. The one subform then has multiple "requirements" per Title. So i have a many-1 relationship between the requirements and titles. On the main form, there is an edit button - so everything is locked until the user hits the edit button, and then the main form becomes editable. The requirements subform does not - it stays locked even though in my code I have "Me![Requirements Subform].Locked = False"
But this is not my main concern right now. What gets me is that I can not add a new record from the requirements subform. For example, Title 1 (T-0001) has 11 different requirements. I can use the navigation to browse through the requirements but I can not add a new requirement from the navigation buttons. This is a main concern.
Another main concern is that when I add a new Titles record from the navigation buttons, my requirements subform disappears from the form.
I hope I explained my situation clearly! if anyone needs any clearification, let me know.
I have some code that will run if I am populating an empty table(no duplication's possible) but now I am trying to create a Sub to check for existence of a record and handling it going forward.
Anyways the big picture is looping through a text file and placing data where it needs to go. The code follows including some comments point to the issue.
Code: Sub PutinNewTag(TableIn As String, Tagtype As String, textline As String) Dim strSQL As String Dim NameIn As String Dim TagName As String Dim Db As DAO.Database Dim rstin As DAO.Recordset
I have button the when pressed will insert a record (via an insert into query) to the frmMain and several records to the frmSub.The problem is when a new record is created in the main form the auto number primary key advances. This is fine however the linked Child field which is a foreign key of the main form is not added and the value is blank. I thought this would happen automatically and the Master field would force the child field to be update but this is not happening.Do I have to determine the max number used in the auto number then add 1 to it?
I have a main form with several subforms in tabs. From one of the subforms I list linked records to the main form (Clients) within that subform (Bank account details). I list the records and have a button to add new records.
Where the Client has one or more records in the subform the add button works perfectly.
When the subform has no records the add new records button produces the following error "Run-time error '2498' An expression you entered is the wrong data type for one of the arguments"
The add button has
Private Sub Command52_Click() DoCmd.OpenForm "AddClientBankDetailsFrm", acNormal, , , , acFormAdd, OpenArgs:=Me!ClientId End Sub
the "AddClientBankDetailsFrm" popup form has
Private Sub Form_Load() If IsNull(Me.OpenArgs) = False Then MsgBox "Form was opened with ClientID = " & Me.OpenArgs Me!ClientId = Me.OpenArgs Else MsgBox "No ClientID was passed." End If End Sub
ClientId is the primary key of the main form and the secondary key in the new record.
I am working with a database that deals with trailers. What is happening is a salesman takes an order for a make and model for a trailer for a customer. The customer can then add some customization to the trailer such as more tail lights or tie down straps. They add the customization on a form called frmCustomQuote. On frmCustomQuote there is a subform called sfQuoteConfigs. On sfQuoteConfigs there is fields such as category and sub catergory that get populated bases on what was selected.
On frmCustomQuote there is a button called "Copy Quote" this will allow the salesman to make an exact copy of the trailer and customization. The quotes are held in a table called tblQuotes and the customization is held in tbQuoteConfigs. Now my problem is when I click on Copy Quote it only copies the first record into tbQuoteConfigs. I can't figure out a way to tell my code to move to the next record within sfQuoteConfigs.
My code:
Code: Option Compare Database Option Explicit 'Setup ADODB connection to the tblQuotes Dim adoQuotesCustomQuote As New ADODB.Recordset 'setup ADODB connection to the tbQuoteConfigs Dim adoQuoteConfigsCustom As New ADODB.Recordset 'Dim the Variables
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.
Error 91 - Object variable or With block variable not set
I am getting this error telling me that an object variable is not set.
I know which variable it is but when I step through the debugger it sets the variable and all is fine? Issue is that public variable of a class is not getting set when the VBA Editor is not open?
This code runs fine the FIRST time, however trows up a message the SECOND time it is run.
The error is on the line ".Range"
I am trying to sort records which have been exported to Excel.
Dim LR As Integer LR = 5 Set xlApp = CreateObject("Excel.Application") xlApp.Visible = True Set wbRef = xlApp.Workbooks.Add With wbRef
wbRef.Activate .Worksheets("Sheet1").Activate With ActiveSheet .Range("A2", .Cells(LR, "O").End(xlUp)).Sort Key1:=.Range("C2"), Order1:=xlAscending, Header:=xlYes End With end With
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"
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.
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 "")
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...
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.