I have 4 nested forms:
DataEntryMaster
DataEntryMainSub (subform on DataEntryMaster)
DataEntrySub2 (subform on DataEntryMainSub)
DataEntrySub3(subform on DataEntrySub2)
In the AfterUpdate even of DataEntrySub2, I have code that checks to make sure the field on DataEntrySub3 (it has only one field) has been filled in. If not, I want to set the focus to DataEntrySub3.
The code in the DataEntrySub2 afterupdate event:
if isnull(me!dataentrysub3.productbarcode then
msgbox "You must enter a product barcode!"
forms!dataentrymaster!dataentrymainsubform!setfocu s
forms!dataentrymaster!dataentrymainsubform!dataent rysub2.setfocus
forms!dataentrymaster!dataentrymainsubform!dataent rysub2!dataentrysub3.setfocus
end if
I've used this most-wordy syntax because I couldn't get the shorter syntax (eg, me.dataentrysub3.setfocus) to work at all. However, this STILL doesn't work.
What's really puzzling is that if I run those exact same 3 setfocus statements from the immediate pane, they work fine. But in the afterupdate event, my focus always ends up on a control in dataentrysub2.
Well, the title says it all really. After I click into the subform and type something in a text box, the focus will not return to the parent form, via mouse or tab. I can't even switch the form back into design view, it appears to be totally locked. Has anyone run into this before?
i won't go into details except i am doing databases for cemeteries - very complicated example i have come across two people who have the same name, date of death, buried in the same grave on the same day but are not related and must have seperate records!! my main table has 6 primary keys. [even then i have 2 duplicates who are not related] anyway one of the problems is this i have a main form with 2 subforms. the main form is unbounded. i need to copy information from 1 of 4 queries run by the main form [QBF] to one of the subforms. i don't know which query untill i view the data. when i know which one, i press a command button which copies the information to one of the subforms. when i repeat the actions above instead on the new query data going into a new record on the subform it overwrites the existing data instead of pasting it into a new record. i have tried setfocus command - this works only if i click on the subform and activate it [this defeats the object of the command as i might just as well click in a new record box on the subform]. in essence i do not need to activate this subform at all. i just need to check if a record exists and if it does goto a new record [again this works only if i physically click on the form] any ideas how i can force the cursor to goto a new record without physically clicking on the subform??
If i open a form with a sub form on can i open it so that the focus go directly to a control on a sub form.I have tried to do it with a macro on the on open event to go to control but it comes up that the control don't exists on the sub form.i am using access 2010.
When I click on my subform after entering some data in the primary form, I get this error message:
"The Microsoft Jet database engine can't find a record in the table <name> with key matching field(s) <name>. (Error 3101)"
This is because I have not filled in a ItemCode, a combobox, on the parent form and ItemCode is part of a one-to-many relationship that involves automatic filling in of other fields such as ItemDesc, UnitPrice, etc. How do I code the validation that handles such an error?
I have a single main form with a datasheet subform. When I scroll through the records shon in the main form, each has a different set of child records shown in the subform.
I want the focus to be on the last record of the subform each time.
On the main form, I have a button and this code
Code: Private Sub cmdLast_Click() Me.frmRevisionsSub.Requery Me.frmRevisionsSub.SetFocus Me.frmRevisionsSub.Form.txtRevTag.SetFocus DoCmd.GoToRecord , , acLast End Sub
which works perfectly, when I click the button.
If I call this code from main form's OnCurrent, focus remains on the first line of the subform instead of going to the the last. I have an inkling that it has to do with when the requery of the subform takes place, when I scroll through the records on the main form.
I have a form with a subform which is sized to show several records at the same time. If Record A has the focus, and I click anywhere in Record B, then Record B gets the focus, as expected. ... Except if I click on an Image field in Record B, when the focus stays on Record A.
How I can force it to set the focus to the other record ? I don't think this can be done with Events handlers, as they need to have the focus set first.
Is it possible for an image control to change to a different picture on a form when focus changes to a different record on a subform? I am developing a simple database to record my ever growing collection of TV shows. The form that I use to view my TV show records has an image control on it, I previously had a single image for the entire series (box art for first season). I now want that image control to change to a different picture when the focus changes to a different record on the subform. i.e. when the focus changes from the first season on the subform to the second season; the picture on the main form changes with it.
I have a form that I created that has a tab control. When the form loads, it automatically sets the focus to a field in the subform. This wouldn't be a problem, except when it does it hides the tabs at the top of the form so I have to go and scroll back up every time I click a tab so that I can see the tabs. Is there a way to adjust this? I have tried hiding a field and setting the focus to it and that didn't work. I also tried setting the focus to the actual tab, but that also did not work.
I am trying to highligh a subform textbox a yellow color on focus. However it is highlighting every textbox in that field as it is a continuous form therefore they are all named ThisCount.
Is there a way to highlight just the specific textbox that I am in. I have tried.
Code: Dim ctlCurrentControl As Control Dim strControlName As String Set ctlCurrentControl = Screen.ActiveControl strControlName = ctlCurrentControl.Name Set ctlCurrentControl = Screen.ActiveControl
I am currently stuck on set focus property. I have a main from with nested subform. I am trying to move the focus from last field of the subform to another field on the main form.
Now I have a field name [Securedesign] in frmOrderdetails and I want the tab order to navigate to field [CustomerID] in frmAddresses which is a subform to frmCustomers.
I have a mainform (f1) and a subform (f2). The subform normally is not visible ([Fomrs]![f1]![f2].visible = Fasle). When I click on a command button on the main form, the subform wiill show up on the main form ([Fomrs]![f1]![f2].visible = True). There is another command button on the subform. When I click on the button, it opens up a third form (f3). The relationship between f1 and f2 is master-child, and the relationship between f2 and f3 is also master-child.
After I open the third form, I want to close (hide) the subform (f2), but I got an error saying that I can not "hide an object that is in focus".
I have several forms and subforms that display data, but are not used for data entry. The first textbox on every form gets the focus on open. I'm sure I've seen some way to open the form with no focus on any control!
I am having trouble getting the cursor to change focus after updating a field in my tab control subforms. I have a main form with a tab control and 4 related subforms for each record in the main form.
I have a calendar that pops up with the On Click of my Date field. When the date is selected, it enters it into the field and the calendar closes. For some reason though the user cannot simply go to the next record with the mouse and has to tab to or select another field in the same record first and then click on the Date field in the next record.
I have tried SetFocus to "Hours" (the next field after "Date")and "NextRecord" on every Event I can think of but it does nothing, it just stays on the changed field and the only way to get out of it is to go to another field. I've tried saving, requery, etc. I've also tried the options shown in the forum with no luck and using different events associated with the Calendar form - On Close, Lost Focus, etc.
I have a form that has 9 tab pages. I have an amend button in the form footer that will do a different thing depending on which tab has the focus. How can I find out which tab has got the focus when I click the Amend button?
I have a problem with setting focus to a text box. There is a listview on the form. Double clicking on a row will search the database for that record using SNo field and then display the contents on the respective control. When I click on a row the first time, it works. Clicking on the second row immediately gives the error "error 2110 - Access cannot set focus to the control txtReference. Here is the code....... Private Sub lvwOrders_DblClick() ClearAll Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM tblOrderEntry where sno=" & ListView.SelectedItem, con, adOpenKeyset, adLockPessimistic lblFooter.Caption = "Edit Record"
subRetrieve
End Sub
Private Sub subRetrieve() Form_OrderEntry.SetFocus With rs For i = 0 To lstCostCenter.ListCount - 1 If lstCostCenter.ItemData(i) = !CostCenter Then lstCostCenter.Selected(i) = True Exit For End If Next i
For i = 0 To lstCostCenter.ListCount - 1 If lstCostCenter.ItemData(i) = !CostCenter Then lstCostCenter.Selected(i) = True Exit For End If Next i
For i = 0 To lstDescription.ListCount - 1 If lstDescription.ItemData(i) = !Description Then lstDescription.Selected(i) = True Exit For End If Next i
For i = 0 To lstOrderStatus.ListCount - 1 If lstOrderStatus.ItemData(i) = !OrderStatus Then lstOrderStatus.Selected(i) = True Exit For End If Next i
For i = 0 To lstSalesRep.ListCount - 1 If lstSalesRep.ItemData(i) = !SalesRep Then lstSalesRep.Selected(i) = True Exit For End If Next i
For i = 0 To lstPaymentMethod.ListCount - 1 If lstPaymentMethod.ItemData(i) = !PaymentMethod Then lstPaymentMethod.Selected(i) = True Exit For End If Next i
For i = 0 To lstCallType.ListCount - 1 If lstCallType.ItemData(i) = !TypeofCall Then lstCallType.Selected(i) = True Exit For End If Next i
For i = 0 To lstStatus.ListCount - 1 If lstStatus.ItemData(i) = !Status Then lstStatus.Selected(i) = True Exit For End If Next i
If !Status = "Pending" Then txtReasons.Visible = True lstAssign_Reasons.Visible = False txtReasons.SetFocus txtReasons.Text = !Reason ElseIf !Status = "Assign" Then lstAssign_Reasons.Visible = True cmdSave.SetFocus txtReasons.Visible = False For i = 0 To lstAssign_Reasons.ListCount - 1 If lstAssign_Reasons.ItemData(i) = !Reason Then lstAssign_Reasons.Selected(i) = True Exit For End If Next i End If
how would i go about setting focus on a tab control? i have a tab control on a form with 6 tab pages. i am on page 4 ( bank ) and i have a button to add a bank account. this opens up the add form and i add the account. i then requery the form and the tab goes back to page 1. how do i set the focus back to the previous opened tab?
I have two buttons on a form, one of them adds default information to three boxes, the other clears the info. I want to be able to hide one o the buttons depending on what is in the box.
I know I need to change the focus away from the control in order to hide it, but how do I do it please?
I have this so far, but there is something missing!
i have a main form, in which i have included 2 subforms on it. Now when i am at the last control on the main form, the focus moves to the first control of one of the subforms. However, when i am at the last control of this subform, on hitting the tab key, the focus does not move to the first control of the other subform.
I have a form that allows a user to select from a variety of options and then generate a report. It consists of three option groups:
1) Select a Team: A B C
2) Select a Report: A B C
3) Input a Date Range: From (blank) to (blank)
If you progress down the list and finish entering the enddate and then click the mouse on the Run Report button, nothing happens. The cursor remains blinking in the enddate field. You have to manually re-select one of your previous options on the form to get rid of the flashing cursor and then re-click the Run Report button to generate the report.
The option to include the Run Report button in the tab order is not available, I don't know why, but it is an image if that makes a difference.
Any ideas? I'm thinking I have to set focus for something. I just don't know when or where.