Subform Control Lostfocus
Aug 9, 2005
I've use a set up that works fine on a form but doesn't when used in a subform. Basically, i have a check box and txt box that won't allow anything to be written in it unless the check box is checked. If it is checked and nothing is inputted in the text box, the lostfocus event for the txt box flags the user. It works fine in a normal form and when it's a subform, the lostfocus event does fire when going to another control in the subform. The problem is that it doesn't fire when going to another control not in the subform. Is there anyway I can get the lost focus event to fire under these circumstances?
Thanks,
scratch
View Replies
ADVERTISEMENT
Feb 20, 2015
how I can get GotFocus and LostFocus of all comboboxes. See below the three codes (code 1, 2 and 3) that I've change from an example from the internet. But the problem is that the function "InitialiseEvents" is not running in these comboboxes. If I try the code 4 as an example, the function "InitialiseEvents" is running perfectly. I don't understand why I can't get GotFocus and LostFocus? You can to see two attachments:
Afbeelding1: The codes 1, 2 and 3 are running.
Afbeelding2: The codes 1, 2 and 4 are running.
Code 1:
Code:
Private Sub Form_Open(Cancel As Integer)
InitialiseEvents Me
End Sub
Code 2:
Code:
Public Function InitialiseEvents(frm As Access.Form)
Dim ctl As Control
For Each ctl In frm.Controls
With ctl
If .ControlType = acComboBox Then
.OnGotFocus = "=HandleFocus('" & frm.Name & "', '" & .Name & "', 'Got')"
[code]...
View 7 Replies
View Related
Mar 24, 2005
I have a table with three fields that have a default value set ("Please Provide"). I have controls for these fields on a form, and procedures for the GotFocus and LostFocus events.
GotFocus:
Code:Private Sub cpuSerial_GotFocus()If Me.cpuSerial.Value = Me.cpuSerial.DefaultValue ThenMe.cpuSerial.Value = ""End IfEnd Sub
LostFocus:
Code:Private Sub cpuSerial_LostFocus()If IsEmpty(Me.cpuSerial.Value) = True ThenMe.cpuSerial.Value = Me.cpuSerial.DefaultValueEnd IfEnd Sub
The intention here is to clear the default value when the user clicks into the field, but replace the default value if the field is empty when the user leaves - not altering the control contents at all if the user entered his own data. The end result is that there aren't records where this field is empty - it is either a user-entered value, or the default value.
My VB is not great - but this seems like a fairly rudimentary thing to accomplish, and what I have SHOULD work. But if that were the case, I wouldn't be writing this.
I suspect I might be misusing the DefaultValue property, or maybe the "Please Provide" default value property is better set on the form rather than in the table...
View 2 Replies
View Related
Jun 7, 2006
Hi, hope somebody can help with this problem.
I have a med-large db shared on network. Am under some pressure to split front/back so more people can do data entry, but want the forms to be semi-finished before putting them on everybody's c:drive.
The problem is error handling for required fields. Some fields are required in the underlying tables because if users don't fill them in, reports are useless. But Access error msg for required fields are too strange, users just close down, maybe wrecking the thing. Don't want to eliminate Close button yet in case they get stuck in Access hell.
I got one ( !! ) field locked in well using LostFocus event, but what do you do if users just mouse into fields at random? LostFocus won't work if it never had focus, right?
(Would much prefer to just use unbound form and give choice of "Field is required" and "OK" or "Cancel this record" but realize that's asking for a lot of help here.)
Any assistance you can offer would be MUCH appreciated!! Vba course isn't until July.
Thanks,
View 9 Replies
View Related
Aug 3, 2006
OK. I have searched and searched and every thread dances around similar situations but none seem to address this particular one. I am trying to make a control on a sub form visible/not visible depending on the condition of a control on a main form. The catch is that the control I'm trying to change the state of is on a subform located in a tab control. I've tried a thousand combinations and none seem to work. How do I reference the control on the subform in a tab control?
Main Form: frmMemberMain
Tab Control: TabCtl12
Tab Control Page: 2
Subform: frmChildren
Control on subform: txtRelationship
Can someone please help before my brain explodes!! Thanks! :eek:
View 5 Replies
View Related
May 27, 2014
On a main form i have a continuous subform listing Jobs.
On the Click Event i want to display the personnel and equipment separately in two additional subforms linked to the Job i have clicked on by JobID.
I have tried all sorts of references and currently have this:-
Forms!PersonnelAndEquipmentMovementFrm.PerEquipMov Jobs.JobID = Form!EmployeeSubform.JobID.Text
Which does not work?
View 4 Replies
View Related
Apr 26, 2005
I had a form with two tabs and then added a subform into a third tab. Until I added the subform I could see the tabs at the top in both the design view and the form view. However, since adding the subform, althougth the form looks OK in the design view, when I switch to the form view the tabs are missing. The only way that I am able to get to them is to tab through all my fields until it eventually seems to shift the page up and I can see them. If I switch to another tab and this stage I then have to go throught the same proccess of going through each of the fields until I can see the tabs again.
Hope this makes sense and someone can help!
Sam
View 2 Replies
View Related
Aug 22, 2006
How do you tab out of one subform and into another from the main form. I have 3 subforms and after a user is finished entering data into the main form the first subform sets focus. After data is entered into the subform it’s impossible to hit the “enter” or “tab” key to move onto the next subform.
View 3 Replies
View Related
Feb 25, 2006
I have two forms, ctrlpanel and users. ctrlpanel is acting as the main form and users as the subform. In a module, I have the following code inside a function that is called on in the users subform:
Code: With Forms![ctrlpanel]![users].Form!cmbSection .RowSource = strList .RowSourceType = "Value List" End With
Can't seem to figure out why I get this error. Have tried a couple different ways of doing this with the same result. here is the error:
"Microsoft Access cannot find the field 'users' referred to in your expression."
users isn't a field, it's the subform and the syntax above is how many sites show how to refer to the subform.
JMH
View 1 Replies
View Related
Nov 16, 2007
I have a subform on my main order form. I would like to click a button on my main order form and have it change a control on the subform. For instance, I have 2 controls on my subform, control 1 is a text field, and control 2 is a yes/no box.
When i click the button on my main for order form, I would like it to evaluate control 1 on my subform so that it can adjust control 2.
I would like to see if control 1 is null then set control 2 to yes or true. Thank you in advance for all your help.
View 4 Replies
View Related
Jan 18, 2008
Hi,
how can i focus on a subform control? my main form called form A has a subform called form B. Form B has a button that, when is clicked, starts a new record for Form B source. all works ok while editing form B but when i open Form A and run the same macro, i get an erro saying Form B is not open.
my macro reads-
GoToRecord
object Type Form
Object Name Form B
Record New
the button is placed on form B which is sub form to Form A.
any help really appreciated.
Nigel
View 4 Replies
View Related
Mar 1, 2005
This is probably simple, but I can't figure it out.
I have a table called Household that has a one-to-many relationship with a table called Individuals. The Individuals table has fields called FirstName and LastName. I have a main form based on Household. I want to have subforms in a Tab control based on the Individuals table. So when you click Page 1, it shows the data for the first person in the household, and when you click Page 2, it shows the data for the second person in the household. This would work by basing the subform on Page 1 on a query that finds the Min of FirstName, and basing the subform on Page 2 on a query that finds that Max of FirstName. However, the data in the subforms would not be updateable, because queries based on aggregate functions are not updateable.
Does anyone have any ideas as to how I can accomplish what I'd like to do?
View 5 Replies
View Related
Nov 10, 2005
Ok, I'm new here and I've searched through the forums and found similar questions asked but no one ever seems to have an answer. I've also looked on other forums and still no solution. So here goes...
I have a tab control with several tabs. On half of these tabs are subforms and the other tabs just have text boxes. When you click the any of the tabs, the entire tab control shifts to the bottom of the screen. The user would have to manually scroll up to continue inputting data.
I added a .gotopage method to the tab control and that fixed the problem in that when you click on a tabbed page, the page is positioned correctly on the screen. However, if I click on a tabbed page which contains a subform, I now get a VB error which says invalid page number argument.
If anyone has experienced this or knows a fix, I'd really appreciate it. Thanks! :confused:
View 6 Replies
View Related
Sep 29, 2006
I am in the process of upgrading a database, mostly by borrowing things I like from a similar database. I've borrowed a subform, along with it's underlying query and have modified my tables accordingly. All fields should match up.
Said subform is embedded on a page of a tab control. I've been modifying it regularly in design view, but when I switch over to form view, none of my controls show up. It just shows a blank yellow background.
This makes me very sad/frustrated. Please help!
View 3 Replies
View Related
Nov 15, 2004
I know how to refer to a control on a form by using [forms]![formname]![controlname], but can anyone help with referring to a subform.
I have a subform called subPrograms, on which is a combo box whose contents need to be filtered depending on the selection from another combo box on the main form.
The combo box on the main form is cboDivisions.
The combo box on the subform is cboPurchasers
Main form is called frmMain
Subform is called subPrograms
The user is supposed to select a Division, and then depending on that selection the contents of cboPurchasers will change to only show those that are within that same division.
I would also like to know how to update the cboPurchasers when the cboDivision has been selected? Can someon help?
I hope that this is enough info.
View 2 Replies
View Related
Sep 2, 2004
I'm trying to check if a control on the subform is null. I've the following line of code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Form!FrmOrderInfoMain!SubFrmOrderInfo.ItemC ode) Then
Msgbox "Empty ItemCode"
End If
End Sub
..whereby FrmOrderInfoMain is the parent form and SubFrmOrderInfo is the subform. I get an error for this code as Im not sure what is the correct code to use. Thanks for the help.
Swee
View 7 Replies
View Related
Dec 16, 2004
I have a control called TotalPaid in a subform Footer section that sums up payment Amounts in the Details section. TotalPaid's control source is simply =SUM([Amount]).
That's it. Nothing tricky, I'm not summing up calculated controls or anything...
PROBLEM: TotalPaid frequently displays "#Error".
I can determine absolutely no reason for this. It is inconsistent, and is not specific to any certain subform records or mainform records. If I go to the next mainform record and then go back, the #Error will often disappear, to be replaced by the apprpriate SUM value.
Is this an Access 2000 bug?? I need to know what causes this and what I can do about, since the value in TotalPaid is VERY important to many of my other calculations. When it gives an #Error, my whole app becomes worthless.
View 4 Replies
View Related
Nov 26, 2013
I currently have a form with a combobox that I want to use to control a subform that I have inserted. Both the parent form and the subform are pulling data from a different table. From the combobox, I want the user to be able to choose a persons name, and then the subform will display each project that the person has worked on based on the name that has been chosen. The reason that I have a subform is so that the user is able to click through projects that pertain to a certain employee. I have the master fields and child fields linked on the employees name as there are not to many employees and the names are all unique.
View 3 Replies
View Related
Nov 4, 2014
I have a form that incorporates 2 subforms. I have all but 1 thing working as intended. I have setup a button to submit the entries (and handle a few other control functions) but I need to validate a single control within the first of the 2 subforms. This should be simple but it seems I am missing something. I just need to check for null or blank and if true open a message box to explain that it is a required field and to then exit the sub without any further execution. My problem is that no matter how I type the code I cannot get it to recognize the control (which is a combo box). Even identifying the from the control is on does not seem to work.
View 1 Replies
View Related
May 15, 2015
I am trying to set a value to a control in my subform (On Load) but it is not working.
FRM_ASQ has a button upon clicking open a FRM_Planchange_Input which has a subform FRM_PlanChange_Input_Details.
On Load - I assign values to controls in the FRM_Planchange_Input and I am trying to assign values to control in the subform FRM_PlanChange_Input_Details.
On Load,
SetPropery -
Control Name: [Forms]![FRM_Planchange_Input]![FRM_PlanChange_Input_Details].[Form]![ASQ]
Property: Value
Value: =[Forms]![FRM_ASQ]![ASQ #]
I am copying the data in Form ASQ to Subform Plan Change Details. Whenever the macro is run, it gets stuck at the point giving an error "The control name is misspelled or refers to a control that doesn't exist. If the invalid control name is in macro, an Action Failed dialog box will display the macro name and the macro's arguments after you click OK."
Upon clicking OK, i get Error Number 3021 - Arguments [Forms]![FRM_Planchange_Input]![FRM_PlanChange_Input_Details].[Form]![ASQ]
The syntax I used is based on this article: Forms![main form name]![subform control name].Form![control name]. I also read that Subform Control Name and Subform Name are not the same?
View 3 Replies
View Related
Aug 4, 2005
Hi,
I'm trying to reference a control in a subform from a module but I keep getting errors!
Here's what I've tried.. and what error I've been getting:
First try:
GetCboEntries = Forms.frmMain!frmSub.Form![cboEntries].Column(1)
(where frmSub is the name of the actual form in the subform control)
Error: Object doesn't support this property or method
Second try:
GetCboActivities = Forms.frmMain!chdMain.Form![cboEntries].Column(1)
(where chdMain is the name of the subform control)
Error: Object doesn't support this property or method
Third try:
GetCboEntries=Forms!NameOfMainForm!NameOfSubform![cboEntries].Column(1)
Error: Run-time error '2450':
Microsoft Access can't find the form 'frmMain' referred to in a macro expression or Visual Basic code.
Any help would be much appreciated!
Thanks in advance!
View 1 Replies
View Related
Feb 21, 2005
Lets say I have Form A and Subform A with the parent-child relationship established that works well. Subform A has a Text box control that is getting display when I include the subform in Form A.
Now, I decided I dont want to include subform A in the Form A. Is there a way for me to show the contents of that Text box control in Form A without attaching the subform in the main form (Form A)?
I read somewhere that to refer a control on a subform, I have to use the code - Forms!mainform!subform.form!control. But this would be in VBA. What is the equivalent of this in a Control Source in the main form?
If I have not explained myself correctly, please do let me know.
To summarize, my question is without including the subform, I want to reference the values of the subform in the mainform. (I have some design necessity for this requirement) Is there a way for this?
thanks!
View 1 Replies
View Related
Aug 16, 2005
Hi
I have read through this forum and found some help on this but can't get it working.
I have a subform
Activity
Contains a tab control with two tabs
Activity Details - Persons
I want to copy the address field from Activity Details tab to the Address field on persons tab
Code for the on click even twon't work. Can't find errrors. I know it is because I haven't referenced it properly.
Me.txtpersonBuildingNameNo = Me.txtactivityBuildingNameNo
Any help :)
View 3 Replies
View Related
Feb 24, 2006
I have attached a condensed copy of my form/sub-form that has calendar controls on it for the RecvdDt and the Compliance date. I have it set up the say way as I have on other databases and it will not close/populate once opened. I have reset the events on it multiple times and I just can't get it to go.
Can anyone please take a quick look and help me determine why it is not working on this form yet works on others that I have.
Thanks.
View 5 Replies
View Related
Mar 15, 2006
Hello everyone...
I have a form that I want to copy selected field values to another form & subform.
I have no problem copying some field values to frmEndorsement... but I can't figure out how
to copy the other field values to the frmEndorsementSubform. I tried several ways but I'm still
on a dead end...
Here's the actual example...
I want to transfer some selected fields from "frmEncounter" to "frmEndorsement" & "frmEndorsementSubform"
In my frmEncounter, I have these fields...
mdsunit, patientID, lastname, firstname, pcp, & encountID ( EncountID is autonumber-PK)
In my frmEndorsement, I have...
patientID, lastname, firstname
& in my frmEndorsementSubform, I have...
pcp, msdunit, & encountID ( encountID is numeric-long integer )
There is a link master-child field between frmEndorsement & frmEndorsementSubform which is patientID.
and below is my code that I got from Ms. Candace Tripp...
Thanks in advance... Jim
Private Sub cmdcopy_Click()
On Error Resume Next
Dim bOpen As Boolean
Dim ctl As Control
Dim frm2 As Form
Dim ctl2 As Control
' check to see Endorsement Data Entry is open
bOpen = IsOpen("frmEndorsement")
If Not bOpen Then
' open form
DoCmd.OpenForm "frmEndorsement"
End If
Set frm2 = Forms!frmEndorsement
' send data to frmEndorsement
' look at each control on frmlEncounter
For Each ctl In Me.Controls
' only look at combo boxes and text boxes
If TypeOf ctl Is TextBox Or TypeOf ctl Is ComboBox Then
' now look at each control on frmEndorsement
For Each ctl2 In frm2
If TypeOf ctl2 Is TextBox Or TypeOf ctl2 Is ComboBox Then
' if the control names are the same,
' set the value to that control on frmEndorsement
If ctl.name = ctl2.name Then
ctl2.Value = ctl.Value
End If
End If
Next ctl2
End If
Next ctl
Me.PCP = Forms!frmEndorsement!frmEndorsementSubform!PCP
Me.EncountID = Forms!frmEndorsement!frmEndorsementSubform!Encount ID
Me.mdsunit = Forms!frmEndorsement!frmEndorsementSubform!mdsunit
End Sub
View 1 Replies
View Related
Jan 12, 2005
I have a control on my main form which attempts to total the amount from all subrecords on that record. For example, I have fields called ValueA and ValueB in the subform. If I have 5 subrecords in a record, then I want the control to sum all 10 fields (5 for ValueA +5 for ValueB). How can I do this?
View 14 Replies
View Related