Modules & VBA :: Calling On Current Event Of Another Form
Apr 20, 2015
I want to call the "On Current" event of another form.
I have a parent(mainform) form and then I have a subform(CurrentForm) and in that subform(CurrentForm) I have another subform(mysubtab01). From the mySubTab01, I want to call the On Current of the parent form. How can i do this?
This is an example of how I am setting the record source of the deepest subform where I want to call the parent on current from:
Forms(mainform)(CurrentForm)(mySubTab01).Form.Reco rdSource = "Select * from subQrytab03"
I have a form with a subform. In the form's On Current event I have the subform's visible property set to false. There is a button that when clicked sets the subform's visible property to true. I want the subform to go to the first control in a new record which is a combo box. the subform is a multiple items form. I have tried the GoToControl in the subforms OnCurrent event, but it is not working. I get an error saying the database cant find a third form.
We have an ActiveX grid control, 10Tec iGrid, written in VB6. One of its method, Group, used to group rows, raises the AfterAutoGroupRowCreated event so the developer can adjust the look and contents of every group row created during the automatic process of grouping.
When our ActiveX grid is hosted on an MS Access form and we call the Group method while populating the grid in the form's Open event, the AfterAutoGroupRowCreated event isn't triggered. But this event definitely works as expected in other development environments, and even in MS Access if we call Group from the form's Load event.
Is it a well know issue of MS Access, when any events of ActiveX controls aren't triggered while "executing" the Open event
I am struggling trying to execute a function inside a Form_current event to display some stats.
The Function is this:
Code: Function FlightsByAircraft(Aircraft As Long) As Long Dim rst As DAO.Recordset Dim dbs As DAO.Database Dim str As String str = "SELECT * FROM tblFlights WHERE AircraftID = " & Aircraft
[Code] ....
The code for the Form_Current event is this:
Private Sub Form_Current() txtStats1 = FlightsByAircraft(Me.AircraftID)
Very simple. Well, the problem is when I move to a new record, a error message comes up: "Run-time error '94' - Invalid use of Null". It is because the AircraftID is not populated at that time. I tried to insert in the function code something like that:
Code: If IsNull(Aircraft) then exit function else .... (the DAO.Recordset code)
I have created a custom message box form that suits my needs for this particular situation. It is called (opened) in the middle of a bunch of other VBA procedures. What I am having a problem with is how do I "pause" the rest of the code from running after the message box call?
For example, with a regular msgbox() function, once called, the code will wait for the user input or click of a button, then continue. My problem is that I am using the basic docmd.openform procedure, and it opens the message box form just fine, but then continues on with the rest of the code after the form is opened.
How would I "pause" the code after the call of opening my custom message box form, then continue it after the user clicks one of my closing buttons from that form?
Furthermore, although its not entirely needed in this situation, for future reference, how would I have that message box form return a value to the calling procedure?
So Access was unable to manage the amount of content that I needed to produce in a single report. The reports contain 12 charts/graphs all of which I needed on separate pages (one chart per page). As such I could not create large enough charts in access to fit to each page, as Access limits the amount of space one can use in a report.
I downloaded Microsoft Reports Builder 3.0 and built my reports as needed and can generate them as desired at current. I'm wondering if there a way to call that RDL file I created to generate my reports from a form control button in Access?
I have been tasked to create a multi-keyword search form, however, my form isn't working right and only the first record of the table is opened.
Code: Public Sub txtSearch_AfterUpdate() Dim strWhere As String Dim strWord As String Dim varKeywords As Variant Dim i As Integer Dim IngLen As Long
[Code] .....
These are the codes that I am using for my search form. I have a feeling that I am not calling the variable from the after update portion the right way.
I have 28 combo boxes on a form, which I want to insert data into the table as they are changed. Each one will pass the same sets of data just with different parameters which come from the form.
Rather than putting the same code to insert on each of the 28 combo boxes I thought it would be easier to create a function to do it and pass the parameters to it through a sub on the AfterUPdate event of the combo box.
I need to pass 4 parameters, if I only put 1 in there it works fine, but when I start putting more in it doesnt work and I get compile errors or syntax errors.
Sub routine:
Code: Private Sub cboMonday1_AfterUpdate() If Me.cboMonday1 = 1 Then Me.cboMonday1.BackColor = vbGreen Me.cboMonday1.ForeColor = vbBlack
I have two fields in my form contained Start time and End time. Currently, Both fields using default Time$() on form. However, End time always wrong because until we get our job done, It took atleast 20 or 30 minutes more than current default time. My question is, is there any way I can setup the End time to just click on it, and a new current default time populated?
Private Sub Form_Current() If Not Me.NewRecord Then With Me.Q_Subform.Form .RecordsetClone.FindFirst "N=" & Me.N .Bookmark = .RecordsetClone.Bookmark End With End If End Sub
The problem is that when the Q_Subform has no records I have the error 3021.
How can manage it. It's the last step before ending My db
I have never tried passing variables while calling a function so I don't know what the heck I'm doing. I'll give a simplified example of what I'm trying to do. The second variable vRank is reporting properly but the first one vID gets "stuck" on whatever the first item in the listbox is.
Code: Dim vrt As Variant Dim upSQL As String For vrt = 0 To Me.List1.ListCount - 1 If Me.List1.Selected(vrt) = True Then Call ChangeUp(Me.List1.Column(0, vrt), Me.List1.Column(1, vrt))
I have code for calling stored procedure with parameters,which is as follows
Dim qdf As DAO.QueryDef, rst As DAO.Recordset Dim IdValueToProcess As Long
IdValueToProcess = 221177 ' test data Debug.Print (IdValueToProcess) Set qdf = CurrentDb.CreateQueryDef("")
[Code] ....
And my stored procedure is
Code: ALTER PROCEDURE [dbo].[spItemDesc] @ItemNo varchar(200) , AS BEGIN set nocount on ; select ProductDesc1,ProductDesc2 from ProductDatabase.dbo.tblProductInfo where ProductNumber = @ItemNo END
I have On Load, Current, After Update events on a form, which all work fine. But, when I add a Before Update, I get the error: "Procedure declaration does not match description of event or procedure having the same name". Following is my code:
Code:
Private Sub Form_Load() If InStr(Me.Filter, "=") > 0 Then If IsNumeric(Mid$(Me.Filter, InStr(Me.Filter, "=") + 1, Len(Me.Filter) - InStr(Me.Filter, "="))) Then Me.Tag = (Mid$(Me.Filter, InStr(Me.Filter, "=") + 1, Len(Me.Filter) - InStr(Me.Filter, "="))) End If End If
I have an order form with an order details sub form. Both are bound to their respective tables and function correctly, with the OrderID being inserted automatically into the order details table.
However I am using VBA to update and check stock and have it working when attached to a separate form called process orders. Which event would be the best place to place this code. I do not really want to have the process orders form. Would it be on the master form or the sub form. I thought of placing it in the after insert event on the subform, but there can be many order items per order and it will run before I have finished adding order items. I tried it in the after insert event on the master form, but I think that this will run the code too soon as at this stage the order details will not have been written to that table.
I was wondering if you can call a textboxes onExit event from another form? On my form a user enters a search criteria into a text box and when they exit the textbox the results are displayed in a listbox. This form is a subform on my main form. I want to be able to call this onExit method from the main form. Is that possible? When I put in txtSearchBox_Exit, I got an error saying Sub or Function not defined.
I would like to make clickable labels on my form, so if the user has any questions about the field, clicking on the label would bring up a message box that would give them more information. I know how to write onclick events one by one for every label, but there are a lot of them, and I feel like there has to be a better way.
I put the label names, and the text I'd like for the message box in a table, and I'd like to have a module that will allow me to click on a label, and have the right text come up.
I've researched ways to do this and have come up with nothing. The farthest I've gotten is an array tied to the form open event that just displays all the message boxes from first to last, one after the other. I believe that's on the right track, but is not a workable solution as is. I need to be able to tie the message box to the actual label the user clicks.
We use our CRM for entering client orders, which is done through our 'OrderEntry' form. On that form we have a subform that we use to enter order lines - as we have a range of products on offer, an order can be made up of one product or anything up to 100.We have an 'amount' textbox on the subform, that the users enter the cost of each line, and as they add more lines the total cost of the order is calculated using a textbox in the subform Footer, with the ControlSource set to =Sum([amount]).
On the main form, we have a Net textbox, that the user will add in the total cost of the order once they've added all the order lines, and providing the =Sum([amount]) textbox on the subform matches the figure in the Net textbox, a button to Proceed the order and go on to the next step appears.
The intermittent problem I have, is that the OnCurrent event I use to show the Proceed button does not seem to fire on its own - but when I stop the code and step through it, it will show the Proceed button without any problems.Here's the code:
(the Proceed button is referred to a 'Command80')
Code: Dim OS As String Dim UT As String OS = OrderStatus UT = fGetUserType
[code]....
I've made the part that refers to the Proceed button bold, but thought I'd add in the whole OnCurrent event in case there was anything in there that was blocking it.
I added in the MsgBox code at the bottom to make sure the OnCurrent was firing, and that works fine.I've searched through the rest of the code, and there's nothing else in there that references the Visible property of the button.I've been through the decompile process detailed here, and also been through this similar thread with a fine toothcomb and this still won't work.
I've saved the form out as a textfile and then imported it back in, both through the immediate window, and short of importing everything in to a new DB and starting again
Private Sub PrimaryDisability_Change() Select Case Me.PrimaryDisability Case "Other (Specify)" PrimaryOther.Visible = True Case Else
[Code] ....
My problem is that when I go to a new record, the fields that I want hidden in the new record unless they meet the criteria are still visible. I have looked all over online and in books to determine the code I use or whatever I need to do to make the field invisible in the new record and only to appear in each record if it meets the criteria.
I currently use code in a module and code on each form in the on_load event to change the icon of the form.. the code i use is as follows..
in a module:
Code: Private Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long Private Const WM_SETICON = &H80 Private Const IMAGE_ICON = 1 Private Const LR_LOADFROMFILE = &H10 Private Const SM_CXSMICON As Long = 49 Private Const SM_CYSMICON As Long = 50
[Code] ....
And on each form on load:
Code: SetFormIcon Me.hWnd, "k: est directoryhsicon.ico"
What I am wondering is would it be possible to store the .ico file within the DB file itself (i know access can store bitmaps) and reference the .ico in the form load event code?
Overtime the db file will probably move to its own dedicated storage so using a direct reference to the file wont work..
I have tried the following but get an error (it tries to reference the .ico file as to being in the root directory of the db file)
I have the following function that I found online. Unfortunately I can't remember where I got it since I've had it for a little while. Today, when I tried to actually put it to use it didn't work.
I'm calling it from a form as follows: CompactDB (tblHotword)
tblHotword is just a random table from the back end. My understanding of the function was that it would use that table to connect and get the file name of the back end.
Whenever I run it, Access pops up a window that says "Object required" and nothing else. It doesn't look like a standard error message popup. When I click 'OK', Access continues with the rest of the code as if nothing went wrong. The function doesn't run though.
Code: Public Function CompactDB(TableName As String) As Boolean On Error GoTo Err_CompactDB Dim stFileName DoCmd.Hourglass True stFileName = db.TableDefs(TableName).Connect