When I tab through records in my (datasheet) form, the tab key behavior is as expected; Focus moves to the next field, and then at the end of the fields moves to the next record. In forms where I have master-child subdatasheets, when the subdatasheet isn't expanded and the user tabs past the end of a record, focus moves to the next record. This is good / what I want. When a subdatasheet is expanded and the user tabs past the end of the master record, focus moves to the first field in the child subdatasheet. Again this is good / what I want.
What happens on the next tab key press is my issue. Rather than moving focus to the next field in the subdatasheet, focus goes straight to the next record in the master datasheet. I expect and want focus to go to the next field in the subdatasheet.
I have been playing with the tabstops and cycle properties on both the main form, subform, and subform control within the main form, and cannot come to a configuration where I get the behavior I desire.
Solved this now and thought I should log it here. Was a pretty stupid problem caused by an oversight on my part.
Basically, all of the controls on my subdatasheet were being set to locked and tabstop = false, in a procedure I have to apply control settings by control name. So I'd actually made those settings a while ago, forgotten, and then assumed that the user should be able to tab through them.
Obviously Access was hitting the subdatasheet control, going "no controls available to tab through here", and so immediately exiting the subdatasheet control.
When I was trying in code to set focus to any of the controls, the reserved error 2950 must've been because the controls weren't tab-stoppable.
Related
I have a Tab Control element containing 2 tabs: Tab1 and Tab2. Tab2 contains a ListBox element whose RowSource queries the data that gets submitted in Tab1.
Say the user opens this form containing these 2 tabs. They are originally on Tab1. in the Form_Load event for Tab2, it queries the data it needs to populate its ListBox. Now they switch tabs to Tab1. They enter some data and submit a new record to the corresponding table (the same table that the Tab2 ListBox uses as its RowSource). When the user switches back to Tab2, they don't see this newly added record.
What I have done so far is that when the user clicks anywhere in the ListBox, it calls Requery, and then the record will show up. This isn't enough as it's not intuitive for the user to have to click on the listbox to update its contents.
I have tried putting this Requery code in a Form_Load, Form_Activate, GotFocus, but nothing works. I know you can detect the TabControl clicks, but how can I access the forms and the elements that they contain?
Any ideas on how to requery this listbox whenever the tab gains control?
If you want to add code for a specific tab on a tabcontrol, the most convenient way to do that is to write code in the TabCtl_Change event. That occurs when the tab control is changed. E.g.:
Private Sub MyTabCtl_Change()
If MyTabCtl.Pages(MyTabCtl.Value).Name = "Tab2" Then 'The tab control just changed to your page
'Requery that list box
End If
End Sub
Note that, if you're not using a tab control at all, but a navigation control (which it does sound like, tab controls don't necessarily have subforms on them, and don't have Form_Load events, forms do)
You're most likely looking for the On Activate trigger.
Then, in the code just use Form.Requery or Form.Recalc depending on which you're actually looking to do.
Alternatively, you could use the same control the user is using to submit records to trigger a requery. Although, that would require a specific Form to be called into focus.
In Microsoft Access 2007, in a table/query in datasheet view, the UP/DOWN arrow keys act as one might expect: they they move the focus up/down by one record, to the same control as in the previous record. It's similar to moving around cells in Excel, and makes it easy to quickly move around a datasheet to adjust values.
However...on a form with a detail pane, the left/right arrow keys act instead like TAB and SHIFT+TAB. They move the focus back & forth through the controls in the defined Tab Order, rather than back & forth through the detail records.
I cannot find anything in the Access Options, help file, or Google to explain how this might be changed.
Without changing the Tab Index or Tab Stop properties of the controls, how do I make the arrow keys move focus back & forth through the detail records on a form, rather than back & forth through the controls in tab order..???
I'm fairly new to microsoft access and i'm currently designing a database for my company but I'm having some trouble trying to get the tab control to work properly. The problem is whenever it navigates through all the pages, when it reaches the last field to fill in, it goes to the next record but stays in the last page, it doesn't 'reset' back to the first page so it follows a logical order.
HansUp offered a good suggestion in his comment, but you may not want to unconditionally SetFocus the first tab in OnCurrent because that could cause the tab focus to switch as users navigate from one record to another using the record selector buttons. There could be cases where the users might find that annoying.
Instead, you might want to use the LostFocus event of the final field to manipulate a flag that would allow OnCurrent to SetFocus the first tab when the user moves to a new record by "falling off the end" of the previous record, but leave the tab focus alone if the user is just stepping through the records.
I'm designing a Form in Access 2003. My goal is that when the user double-clicks on a record (aka Detail), a second form opens. This is easy enough to do when I start from scratch.
But of course, I'm not starting from scratch. I've been working on this for a few hours now, have added some conditionally formatted textboxes, fields, etc, and don't want to start over if I can avoid it.
I don't know if I turned on/off some obscure property, but I've been working on this form for a few hours now and the Double-Click event of the Details section only triggers when I double-click on the first record or any other with conditional formatting.
To troubleshoot this, I've gone so far as to comment out all the other VBA script except this:
Private Sub Form_Load()
Me.Application.DoCmd.Maximize
End Sub
Sub GotoFrmDetails()
MsgBox "You Double Clicked Me!"
End Sub
Even with the VBA script reduced to just these lines, the DoubleClick event only triggers on the first record and no other. Can anyone tell me what wrong? I'd rather not have to rebuild this from scratch.
I find the click events of form sections to be more trouble than they are worth (click event doesn't pass through to the form if user clicks on a control or label, etc). What I use instead are transparent command buttons.
Just add a command button to your form and set its Transparent property equal to True. Then you can use the Z-order to make fine-grain changes if necessary (send to front/back, send forward/back).
They can be hard to find once you make them transparent, so be sure to give them descriptive names.
If you want the user to be able to double click anywhere in the detail section, just make the transparent command button's height/width match the section height/width.
Move your code from the Detail section DoubleClick event to the transparent command button's DoubleClick event and you should be good to go.
I'm wondering if the rows are getting their Locked property set to Yes, or their Enabled property set to No during your condition formatting.
I have a continuous subform in an Access 2003 form. The first control on the subform is an unbound dropdown box. When the form (and subform) are opened the dropdown on the first record receives focus, but the text is blank (just a blinking cursor). If I click on any other record, the first record's dropdown text then display the correct value (and the record I clicked on does not go blank).
I tried the following line
Call DoCmd.GoToRecord(acDataForm, "DetailsSubform", acNewRec)
in the both the main form's and subform's Load, Open and Activate events with no luck. Either I get an error that the subform isn't open, or there's a conflict with the routine that populates the dropdown.
I'm looking for a way for either the dropdown to display its value, or simply jump to a new record (my client would prefer the latter but can live with the former). More information can be provided if needed, I just wanted to start with an overview. Thanks.
You probably need the current event. Note that an unbound control in a continuous subform will display the same value for all records.