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 Replies
ADVERTISEMENT
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
Nov 13, 2006
I have the following query, named "Query9" (Right, I didn't assign it a name when I first created it). Its SQL is:
SELECT LA.DL_ID, LA.UPB, LA.[FMLNo]
FROM LindActivity AS LA
UNION ALL SELECT [Q].[Deal ID],[Q].[CSUPB],[Q].[CBIID]
FROM [qry_DSRCB] as Q;
Both LindActivity and qry_DSCRB are queries, neither of which makes any reference to "Query9".
This query runs fine. However, when I change its name to PCBStack, it can't find Query9.FMLNo. If I change its name back to "Query9", it runs fine again.
Also, if I copy the SQL from Query9 and create a new query, PCBStack, and paste the SQL into it, it runs fine.
Anyone have any idea what is going on? I am using Office 2003 with Windows XP
View 1 Replies
View Related
Mar 16, 2015
How to trigger the below VBA Code under one Change() Event once a selection is made from the only combobox on my form.
Code:
Private Sub cbxAssociate_Change()
Me.txtFIRJuly14.Value = DAvg("FIR_Perc", "tblFIRStats", "[Associate]= '" & Nz([cbxAssociate]) & "'AND [Month] = 'Jul-14'")
Me.txtFIRAugust14.Value = DAvg("FIR_Perc", "tblFIRStats", "[Associate]= '" & Nz([cbxAssociate]) & "'AND [Month] = 'Aug-14'")
Me.txtFIRSeptember14.Value = DAvg("FIR_Perc", "tblFIRStats", "[Associate]= '" & Nz([cbxAssociate]) & "'AND [Month] = 'Sep-14'")
[Code] .....
View 8 Replies
View Related
Oct 30, 2013
I made an On Change Procedure on a textbox, so everytime I input a character, it will trigger the Me.Requery.
However, after that the event, the mouse cursor moved to the beginning of other field. I want it to stay at the end of the textbox so I can enter a full word, how do I do that?
Code:
Private Sub Text73_Change()
ProjectSearch = Me.Text73
Me.Filter = "[Project Name] Like " & Chr(34) & ProjectSearch & "*" & Chr(34)
Me.FilterOn=True
Me.Requery
End Sub
View 3 Replies
View Related
Oct 7, 2013
I'm working on a bit of code that before a combobox is changed checks with the user to confirm that they want the change to go ahead, if yes a recorded is added to a table
This all work fine apart from if no is selected - I am trying to get the combobox to undo the change however when you select no the msgbox pops up fine but the combobox does not undo
Can't see where I'm going wrong I thought undo worked for comboboxes
Code:
' Displays a message box with the yes and no options.
Response = MsgBox(prompt:="Do you wish to change the status of this Job? 'Yes' or 'No'.", Buttons:=vbYesNo)
' If Yes button selected
If Response = vbYes Then
[Code] .....
View 3 Replies
View Related
May 21, 2015
I have a combo box with three columns, the first one is the bound one, the second is text in English, and the third is text in Spanish. Currently when the form is open, both the English and Spanish texts columns are visible. What I would like to do is set up a command button on a different form that will open the form with just the English showing in the combo boxes, and another button for Spanish. I've tried the following code which opens the form, but the combo box is disabled altogether.
DoCmd.OpenForm "frmEditar", acNormal, "", "", , acNormal
DoCmd.SetProperty "niv_gest", acPropertyColumnWidths, "0;1;1"
What am I missing?
View 5 Replies
View Related
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
Nov 21, 2013
I am trying to write a code that will execute at the change even of the combobox/Listbox and when a character is typed in it then all the data from "DocumentType" field whose first character matches with the first character typed in Combo/Listbox will be stored in it.
The following code doesn't work:
Private Sub ComboBox4_Change()
Dim strText, strFind As String
strText = Me.ComboBox4.Text
If Len(Trim(strText)) > 0 Then
strFind = "BarcodeRef like '" & strText & "*'"
End If
[Code] .....
View 1 Replies
View Related
Jun 19, 2014
I have the following code which errors on line
Code : .OpenDataSource Name:=CurrentProject.FullName, SQLStatement:="SELECT * FROM [qryMailMerge]"
The error (Error has occurred: The database has been placed in a state by user 'Admin' on machine 'W74XXXXXX' that prevents it from being opened or locked) appears in the Word document.
Code:
Public Sub CreateWordToPDF(strWordFile As String, strPDFFile As String, strSQL As String)
'Call CreateWordToPDF("C:Doc1.doc", "C:Doc1.pdf", "SELECT * FROM [qryMailMerge]")
Dim objWord As Word.Application
Dim docWord As Word.Document
'Open MS Word using early binding.
Set objWord = New Word.Application
Set docWord = objWord.Documents.Open(strWordFile)
[Code]......
View 8 Replies
View Related
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 5 Replies
View Related
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
Sep 24, 2013
To facilitate input of special graphic characters such as the degree C and plus-and-minus symbols, I would like to use Alt-1 to Alt-9 key combinations, capture these keys in a KeyDown event procedure and change the keystroke to the desired graphical character code. I am using Access 2010 on Win7.
I first attempted to change the Shift integer to zero to reset the Alt-bit and set KeyCode to the desired character code, but this does not work. Hence I try to use the second common method of setting KeyCode to zero and use SendKeys to VBA-input the desired graphic character. However, strange things happens.
The test code is as follows:
Code:
Private Sub TestTB_KeyDown(KeyCode As Integer, Shift As Integer)
Dim i As Long
If (Shift And acAltMask) <> 0 And KeyCode <> 18 Then
' For i = 1 To 20000000 this For-loop is initially commented out
' Next i
[code]....
The above code as it is works OK and the '#' is successfully inputted to the TextBox field.However, if I comment out the MsgBox statement, the program waits for about 0.3 second and then instantly fills up the entire TextBox field by a large number of '#' characters.
If I move the MsgBox statement to after the SendKeys, no '#' character is inputted to the TextBox.If I comment out the MsgBox statement and activate the For loop at the looping count amount (but not much less), the program works fine.
View 5 Replies
View Related
Feb 18, 2014
I have the following code which works perfectly BUT I want to be able to add another line of text if users enable a checkbox. I have tried everything I can think of but can't get it to work. When using an "IF check150" statement it just adds the extra text in regardless of selection or not.
Code:
Function Mail_Radio_Outlook6(activedoc As String)
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim acc_req As String
Set OutApp = CreateObject("Outlook.Application")
[Code] ....
This is fine most of the time but If a user ticks check150 I want to add another paragraph.
Do I use an IF statement, if so in what format? is it a separate function etc?
I am slowly getting more familiar with Access but still come unstuck on the simplest of things at times.
View 3 Replies
View Related
Aug 14, 2013
I'm using Access 2010. I'm passing a string into the OpenArgs of my report - works fine. In the report there are 3 rich text fields which may contain the text I passed in, and if so I want to change the color of that text to red so it stands out.
The value passed to the report changes so I'll need to use VBA in the detail's format section to check each of the 3 rich text fields.
View 5 Replies
View Related
Nov 5, 2014
I have an on click event to mail a report which works. I want to change the text to include data from a table.
I changed the code to include the field 'office' from the table 'Checks' but get an error saying 'Object required'.
Code is :
Private Sub cmd_mailreport_Click()
Dim office As Object
Set office = Checks.office
DoCmd.SendObject acReport, "checks", "PDFFormat(*.pdf)", _
"info@company.com", "", "", office & " Daily Check - " & Date, "Attached is the report for the office", _
True, ""
End Sub
View 1 Replies
View Related
Apr 16, 2015
I have a continuous form with a text field that says "Select". There are two other fields, one of which is Brand. When the Brand Combo box has nothing in it I want the text box to appear (instructing the user to select a Brand) But once the user selects a Brand and goes to the next records, I would like the "Select" in only that record to become not visible. I tried conditional formatting but can't apply that to an unbound control ( or at least it is grayed out when I select the text box) and any other possible solutions I have found changes all of the selects - not only the one in the changed record.
View 7 Replies
View Related
Nov 26, 2005
I have a data entry form where country(ies) (there can be more than one for
each project) is/are entered in a sub-form on a tab control. Countries not
listed are entered by the following:
Private Sub CountryName_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim strMsg As String
Dim ctl As Control
Set ctl = Screen.ActiveControl
strMsg = "Country " & NewData & " Is not listed!" & vbCrLf & "Do you want to
add it?"
If MsgBox(strMsg, vbYesNo, "Not listed") = vbYes Then
strSQL = "INSERT INTO tblCOUNTRY (CountryName) "
strSQL = strSQL & "VALUES('" & NewData & "');"
CurrentDb.Execute strSQL
Response = acDataErrAdded
Else
ctl.Undo
Response = acDataErrContinue
End If
End Sub
This works fine. However, if I restrict the country names by a region
selection on the main form (for example if region Africa is selected on the
the African countries are preselected) the NotIn List does not work. Any way to work around this?
Another question, I want the user to select a region (a combo box ) on the
main form and when a new country (using the NotInList event) is entered in the subform both values go into
the same record in tblCountry (which has two fields CountryName and Region).
For example, I enter AFRICA for region on the main form and on the sub-form I enter Malawi which is not listed. I have tried the following:
Private Sub CountryName_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim strMsg As String
Dim ctl As Control
Set ctl = Screen.ActiveControl
strMsg = "Country " & NewData & " Is not listed!" & vbCrLf & "Do you want to
add it?"
If MsgBox(strMsg, vbYesNo, "Not listed") = vbYes Then
strSQL = "INSERT INTO tblCOUNTRY (CountryName, Region) "
strSQL = strSQL & "VALUES('" & NewData & "', FORMS!frmAddPro!Region);"
CurrentDb.Execute strSQL
Response = acDataErrAdded
Else
ctl.Undo
Response = acDataErrContinue
End If
End Sub
But it does not work (Region is the control on the main form named frmAddPro).
Any suggestions would be welcome. Thanks.
Niels
View 4 Replies
View Related
Jul 15, 2014
So I have a bound form with the following onload code:
Code:
'Add the percent completed to lblPercentCompleted by calling the function
Dim Completed As Double
[code]...
This works fine and set the caption and color of a label on this form.On this form I have several (now only a few, but in the end probably 40 controls or so) which will get updated by the user. When any of these controls are updated, I want the label lblpercentCompleted to get updated with the propper caption and color, however I am having trouble doing this.
I have an afterupdate event on each control with the same code as the onload code, however the message box below appears but the label does not update.
Code:
Private Sub TransferDieCutsOn_AfterUpdate()
MsgBox "Updating Label"
'Add the percent completed to lblPercentCompleted by calling the function
Dim Completed As Double
[code]...
View 6 Replies
View Related
Apr 19, 2006
ciao people
i've been looking around for days, hope u can solve my problem!
my form is made up of several combo boxes
i wanna write a code which after a selection in any combo box sets the properties of the latter as follow: enabled NO and locked YES (just the opposite of the default value)
can u please help me?
View 2 Replies
View Related
Apr 19, 2006
ciao people
i've been looking around for days, hope u can solve my problem!
my form is made up of several combo boxes
i wanna write a code which after a selection in any combo box sets the properties of the latter as follow: enabled NO and locked YES (just the opposite of the default value)
can u please help me?
View 3 Replies
View Related
Sep 29, 2005
I have a field (AR#) that has an "on change" event. This is supposed to check through the database and see if that number has been here before (it's like a job # / serial #). It had always worked fine - now suddenly this field, and this field only, reacts VERY, VERY slowly when you type a number in. You can type the number and wait about 5 seconds for it to show up. When I removed the event - it acted normally so I think it has to do with that. Here's the vb for the event:
Private Sub AR__Change()
Dim db As Database
Dim Rst As DAO.Recordset
Dim strAR As String
Set db = CurrentDb()
strAR = Me.AR_.Text
Set Rst = db.OpenRecordset("repairs", dbOpenDynaset)
Rst.FindFirst "[AR#] = '" & strAR & "'"
If Rst.NoMatch Then
Else
MsgBox ("This value it is already in the system !")
End If
End Sub
Any ideas why it's reacting so slow or what I should look for?
View 2 Replies
View Related
Mar 11, 2013
I am working with MS Access. The database has 2 tables.
-Parent and Student and ParentID is the Primary key as a parent may have multiple Students
-There is a form that lets me add students for a particular parent
One of the fields in the Parent Table is FeeDue. I added a field in the Parent Table called NumOfStudents..What I want to do is as follows: When a student is added on the Student Form, I want fee to be calculated automatically for display AND update the FeeDue field in Parent table. Event handler executed when a student is added (checkbox clicked)
OnClick()
{
Read NumOfStudents from Parent Table
if(student_added = true)
NumOfStudents++
else /* This is to cover student withdrawl*/
NumOfStudents--
if(NUmOfStudents = 1)
Fee= 400
else
Fee = 500
}
student_added check box is on the student form NumOfStudents and FeeDue are fields in Parent
View 1 Replies
View Related
Jun 14, 2015
I have a basic form linked with a subform inside of it. The main form has a list of customers in a combobox and the subform lists all the things they have ordered from us. This all works perfectly fine, I can add data to the list of things ordered and it's ok.
I decided instead of using a whole extra form to add customers I'd just have a not in list event and allow users to add customers through there, bit more intuitive and cut down on forms.
It works to certain extent except one small problem, if I add a customer I have to close and reopen the form to be able to add/remove data from them in the subform. If I leave the form open and try to enter in data in the subform immediately it just shows whatever customer I had last on the combobox and adds it to the last customer as well.
It works perfectly fine if I reopen it so I thought it was some kind of query or update snafu but all the VBA code examples I found don't seem to do anything. Not exactly sure where to go from here.
PHP Code:
Private Sub cboDept_NotInList(NewData As String, Response As Integer)
Dim oRS As DAO.Recordset, i As Integer, sMsg As String
Dim oRSClone As DAO.Recordset
Response = acDataErrContinue
If MsgBox("Add dept?", vbYesNo) = vbYes Then
Set oRS = CurrentDb.OpenRecordset("tblDepartments", dbOpenDynaset)
[Code] .....
View 6 Replies
View Related
Mar 13, 2008
I am using an active x control that when you right click on it, it automatically pops up an "About" box showing information about the control. I wouldn't object to this, but I need to use the right mouse down event for another purpose in my program. So far I have discovered that the code I put in the the event works, but only after the "About" box pops up. Is there anyway to cancel or prevent the popup? The reason that I need the right mouse down event is because is that I am already using the left mouse double click event, and I can't use the left mouse down event because then it always fires before the left mouse double click event. This control doesn't have any single click events. Ideas?
View 2 Replies
View Related
Oct 2, 2013
I am developing a form whereby the user types a single character or a sequence of characters into textbox and a query WHERE clause is compiled upon each character being entered.
The query is the Row Source of a listbox which I requery upon each change in the text box contents.
In the Change event I cannot access the new contents of the textbox until focus moves to another control and then back to the textbox. This is not how I expect this event to work.
View 3 Replies
View Related