Modules & VBA :: Call Text Box OnExit Event From Another Form

Jun 26, 2013

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.

View Replies


ADVERTISEMENT

Modules & VBA :: Cancel OnExit Event When Another Command Button Is Pressed

May 8, 2015

I have a form with a control for the user to enter some data and then two command buttons 'OK' and 'Cancel'

For the OnExit event in the control I have a procedure that check the user input and if incorrect, opens a message box with an error message asking the user to correct the data. It then cancels the event so the focus remains in the current control.

However if the user presses the 'Cancel' command button on the form to cancel & close the form, the OnExit event for the current control still fires and asks the user to correct the data.

In my code in the control, how can I recognise that the Cancel command button has been pressed, so I can cancel the OnExit event and close the form?

View 2 Replies View Related

Modules & VBA :: How To Call Up Another Event Procedure

Aug 15, 2015

I have 3 event procedure with 3 buttons to make them run.I would like to create another button that can run all procedures togehter. if I copy one of the procedures how do I tell it to run the other 2.

View 2 Replies View Related

Modules & VBA :: Unable To Call Event From Module?

Mar 12, 2014

This is the code I'm trying to run from a Standard Module:

Code:
Public Sub RunPaxCalculations()
Dim frm As Form
Dim intNumberOfRecordsInFilter

[Code]....

View 4 Replies View Related

Modules & VBA :: Call Event From Subform Using Tag Property?

Jul 11, 2013

I am starting to explore VBA and Modules. I recently found a relativly simple way to add an Audit Log to a database without adding two tables for each table as outlined by Allen Browne.

I used a set of code from fontstuff.com and it works great, except when using a sub form. I belive that it is most likely because the use of the Tag property looks at the subform as a control but it holds no value. I am thinking the VBA needs to be altered or the BeforeUpdate command need to specify what form to look in.

The Before Update code is

Code:

Public Sub Form_BeforeUpdate(Cancel As Integer)

Code:
If Me.NewRecord Then
Call AuditChanges("SubForm_ID", "NEW")
Else
Call AuditChanges("SubForm_ID", "EDIT")
End If
End Sub

AuditChanges is the Module Event name and CustomerID is the unique identifer for a Subform.

View 1 Replies View Related

Modules & VBA :: Use Text Box Change Event To Determine Form Format

Sep 23, 2013

Had a combobox so the user could choose between two data entry formats.They don't want the combobox, they want the user to enter data into one or the other textbox - and that choice to trigger the format.Two groups of text box - group 1 has a single text box - group 2 has three text box. When the user selects a text box and types the first character into it. This triggers locking out the other group choice and enables the <Validate and Edit> command button.

If the user backs out (deletes) the text in a text box.It basically makes both groups available again and it disables the <Validate and Edit> command button.Basically, if the text box Change event counts a character, it changes the text box Tag to "Bust". Then it calls a common routine that checks both text boxes.The choice won't take place if the textbox gets focus. It changes if a text box has 1 or more character typed in.

Code:
Sub WhosOnFirst()
' two groups of Required field - if one textbox in a group has a character entered first
' that group becomes the Format - enables the <Validate and Accept> button that will take the next setp

[code]...

View 2 Replies View Related

Modules & VBA :: Click Event To Open A Form And Select Record Corresponding To Value In Unbound Text Box

Oct 29, 2013

I have some code for a button on click event to open a form and select the record which corresponds to a value in an unbound text box. The code is:

Private Sub Command25_Click()
On Error GoTo Err_Command25_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmOpenPatientRecord"

[Code] ....

This works fine when I put in a 10 digit NHS number but opens a blank record when I enter a four digit or six character/digit PatientNumber. Both patient number and NHS number are text fields in the underlying table.

View 14 Replies View Related

Modules & VBA :: Call Value From A Text Box During SQL Execution

Dec 20, 2014

I have this segment of code that adds data to fields FName and FPath in the table Files. It works fine but the syntax is a nightmare with all the double quotes and symbols.

Code:
strSQL = "INSERT INTO Files " _
& " (FName, FPath) " _
& " SELECT """ & strTemp & """" _
& ", """ & strFolder & """;"
CurrentDb.Execute strSQL

I have another field in the table Files called CompletedBy that shows who updated the table (they type their name into a textbox Text1 before clicking a command button to run the code). I would like to add this data to the table during the execution of strSQL. All the records added to the table Files will have that value in the CompletedBy field (say, Bob Jones).I tried the below changes but the code doesnt work.

Code:
strSQL = "INSERT INTO Files " _
& " (FName, FPath, CompletedBy) " _
& " SELECT """ & strTemp & """" _
& ", """ & strFolder & """ & Me.Text1 & """;"
CurrentDb.Execute strSQL

How would I add a value in field CompletedBy, from the textbox Text1, to all records added to table Files when the code is run?

View 2 Replies View Related

How To Call A Form Event From Another Form

Sep 28, 2005

Hello:

Is it possible to call a form event (actually a control's event within the form) from another form?

Thanks in advance.

View 6 Replies View Related

Modules & VBA :: Static Shell Function Call Works But Dynamic Call Fails

Sep 4, 2013

I'm having to recode some old MS Access DBs so they will run in the following environments:

Office 2000 on WinXP
Office 2003 on WinXP
Office 2010 on WinXP
Office 2000 on Win7
Office 2003 on Win7
Office 2010 on Win7

When I wrote my code for Office 2000 on WinXP things were simple because directory paths were the same across all computers and I could hard code pathing when using a shell command to launch other files.

My new approach is to make a function call to the Windows registry to determine the default executable and path for opening a file based upon its extension (see apicFindExecutable in basWindows API module).

I'm able to use code to create a shell call and debug print it to the immediate window. If I put my cursor in the immediate window at the end of the shell call and hit [enter] the external file will open as desired. If I try to open the external file directly through code, I get a file not found error.

To recreate the error take the following steps:

(1) browse to files that are accessible from your computer
(2) click the PREPARE DATA AND OPEN MAIL MERGE DOCUMENTS command button

Shell function call is made by the fnOpenFile function located in the basOpenFile module. There has to be a trick here that I'm missing.

View 5 Replies View Related

Onexit A List Box, Refresh A Combo Box On Same Form - How?

Aug 15, 2005

Hi All,

I have a form with a list box where you can add new names, and a bombi box that lits current names already in use. I want the form to update the combi with the name just typed in the list box. I guess I use OnExit event, but I don't know the code I should use for updating the combi list..

any pointers appreciated.

andy

View 1 Replies View Related

Modules & VBA :: Text Box Change Event Prevents Updating?

Jun 18, 2013

Currently I have an issue where on of the fields in a userForm will not update. I have tracked down the problem to an update Event procedure

Code:
Private Sub txtRate_Change()
Me.txtSales = Me.txtRate * Me.txtPages
Me.txtGST = Me.txtSales * 0.1
Me.txtTotal_Inv = Me.txtSales + Me.txtGST
End Sub

The idea being, when you update the rate, the Sales/Revenue figure will update based on that rate. For a while this seemed to work fine. but recently , it just will not allow me to update the field txtRate, I cannot understand why. I have now replaced the _Change() event for a _LostFocus() event. but I am not sure that is as reliable, and I am still puzzled / worried as to why the _Change event will not work.I'm on Access 2013, win 7 , using a front end db connected to the back end using linked tables.

View 8 Replies View Related

Forms :: Using OnClick Event To Open Query Text Displayed In Form Field?

Oct 10, 2013

I have a table that holds the SQL texts for ca. 1000 Select queries (mostly minor variants that are used to programmatically swap out RowSource strings for combo boxes). I'd like to have a quick and easy way to open/review/modify these queries.

One strategy would be to display the SQL strings in a field on a Datasheet form, then use an onClick event on a text box linked to the SQL-holding field (or perhaps an onClick event tied to an unbound text box on the form) to open the associated query. That would allow me to view the SQL of the query that I want to open, allow me to quickly scroll through the list of stored SQL texts, and give me options for sorting or limiting the SQL-texts displayed in the datasheet form.

But, I can't seem to get the onClick event to work. The problem seems to be that I can't figure out how to pass the SQL string contained in the field to a function that will use that string to open the query .

View 10 Replies View Related

Modules & VBA :: Form Won't Go To New Record On Current Event

Jun 3, 2015

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.

View 4 Replies View Related

Modules & VBA :: Putting A Form BeforeUpdate Event

Jul 19, 2013

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

[code]....

View 3 Replies View Related

Modules & VBA :: Form Event To Update Stock?

Nov 14, 2014

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.

View 4 Replies View Related

Modules & VBA :: Form Current Event Error 438

Jul 28, 2015

I have error 438 Object doesn't support property or method in a Form On Current event.

Error trapping is turned on, reason being I converted the form to accde and it stopped working!

The code is...

Private Sub Form_Current()
On Error Resume Next
Dim ctl As Control
'Me.CC_Spare_3.Enabled = False
For Each ctl In Me.Controls

[Code] ....

The highlighted text when in debugger is

ctl.Locked = Me![Check411]

View 4 Replies View Related

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"

View 12 Replies View Related

Modules & VBA :: Place If Statement In AfterUpdate Event On Form

Nov 13, 2014

I'm trying to place an if statement in an afterupdate event on a form. The code I have is

Code:
If [Customer] Like "BRO001" And [Inv No] is null Then [Job_Price] = [Shots] * 27.5

this gives me a run time error, object required and highlights

Code:
If [Customer] Like "BRO001" And [Inv No] Is Null Then

I'd like the code to do nothing where the requirements to alter the job price are not met.

View 5 Replies View Related

Modules & VBA :: Creating One OnClick Event For All Labels On Form

Mar 18, 2014

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.

View 4 Replies View Related

Modules & VBA :: Form OnCurrent Event Not Firing Properly

Aug 7, 2014

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

View 14 Replies View Related

Modules & VBA :: Resetting Event Procedures For A New Record In Form

Sep 10, 2014

I have the following Event Procedures in a form:

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.

View 13 Replies View Related

Modules & VBA :: OnLoad Event To Change Icon Of The Form

Sep 26, 2014

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)

Code:
SetFormIcon Me.hWnd, Left(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir(CurrentDb.Name))) & "hsicon.ico"

View 2 Replies View Related

Modules & VBA :: Birthday Remainder On Access Form Load Event

Apr 26, 2015

I would like to have a birthday remainder on access form load event VBA...

I have tblEmp with 2 fields,

Name DOB
A 22/04/1977
B 25/03/1965
C 17/08/1985

I would like to compare Date and month with my system date to show in the message box "Mr. A Birthday Today" on the Form load event...

View 12 Replies View Related

Modules & VBA :: How To Access Description Inside Form Error Event

Jul 31, 2013

I'm trying to extract information from Err.Description within a form's Error event. Alas, Err.Description does not seem to be available from there.I have a form that normally displays in DataSheet view. If a trigger on the Oracle back-end raises an error, I want my Access app to be able to parse out Err.Description and deliver a more user-friendly message than ODBC's message. I want to get the info about the message from the error coming back from Oracle, not by matching up error codes.

If I change the form to Single-Form view and put a Save button on it, I can capture Err.Description in the command button's Clicked() event, and then parse out what I need.So if I must display this form in Datasheet view, where can I trap the ODBC error and display my user-friendly message?

View 5 Replies View Related

Modules & VBA :: Subform Event To Update Automatically A Field In Form

Mar 18, 2015

I have a form and a subform

Which method should I use if I need to update automaticaly a field in form based on an event in subform ?

Just to be more clear, have a look in the below example.

In first print screen, student "Johnson Nick" has not completed all tests in TestA subform, the form field "DateCompleteA" is blanc.

Once a student completes all tests in Period A, I need the form field DateCompleteA to show the date that he completed the last one. (18/3/2015).

If student has not yet completed all tests in TestA subform the Form field DateCompleteA must be blanc.

Student has not completed "literature"yet, DateCompletA field is blanc

Student completed ALL his test, subform is updated, Form field DateCompletA is updated with the maximum date.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved