I am using DoCmd.GoToRecord ,,acNewRec in a continuous subform Form Open event.
That causes the continuous form to scroll so that only the new record is visible. I'd like to show 4-5 records above the new record row.
In Form View the new record navigation at the bottom does the same thing, so it seems to be a default Access behavior.
I've tried several combinations of moving in the recordset before and after and then go back to the new record, but I can't get it to work. Thanks in advance for any ideas.
Related
I am working on a simple database in MS Access for small manufacturer. Its very simple and small.
Basically I have a form where workers can log what they did during the day. I have 4 Combo boxes and 3 text boxes.
Every think works like a charm until I close the form. When I close it, it updates first row, but it only changes what was in text boxes, data form combo boxes is the same. E.g. worker enters some data, clicks insert and table is updated with this new information. Then when he/she clicks close this information is inserted in first row in this table, but changes only what was in text boxes.
Same think happens no matter what, if there is data in those boxes or not.
This is how I close my form:
Public Sub Close (formMe As Form)
DoCmd.Close acForm, formMe.Name
DoCmd.OpenForm "WorkerLogin"
End Sub
But I noticed that same think occurs if I ran the form as pop up, and then closing it with X.
I appreciate any suggestions.
Thank you
I manage to fixed it with
Me.Unload
before closing it.
A subform is populated by fields from a combo box, and the record saves as expected. With click on next record in the combo box, the record saved earlier is overwritten. I've tried the following on current in the main form and similar code but nothing works. It still wants to overwrite a previously saved record. Any suggestions?
Me![Forms![frmAccount]![subAccount].SetFocus
DoCmd.GoToRecord Record:=acNext, Offset:=1
The code in the following post did not work either?
Making "DoCmd.GoToRecord" function work on a subform
Use On Change on combo box field in main form and enter:
subFormname.SetFocus
DoCmd.GoToRecord , , acNewRec
I kept trying and came up with this syntax. Let me know if you have anything better.
I have a form with a 2-page tab control.
The first page has a subform with a button on the subform that's supposed to requery another subform that is on the second page.
Forms!myMainForm!mySubForm.Requery
The main form and its fields are used to create new records and the subform on the second page shows these records.
Here's a screenshot of page 1's subform and button:
http://i.imgur.com/RLsgcSi.jpg
When the button is clicked, the subform on the second page shows any new record at the bottom of the list instead of being sorted in descending date/time order. Also the Funding Rate field does not seem to get its conditional formatting applied:
http://i.imgur.com/QRvI5fy.jpg
I've been able to get the subform to display correctly if I also add some VBA to the button to switch to the second page of the tab, but I'd rather not do this.
Is it possible to requery a subform and have it display correctly when the user is ready to see it?
Migrate froms Tabs to Navigation Control. Usual Tabs are preloaded and will increase the main form load time. On the other hand, Navigation control only loads the form when its opened. This eliminates your needs to manually re-query the second tab.
PS: I'm interested in something in your form, what is your best contact method?
Forms!myMainForm!mySubForm.Requery
This requeries the mySubForm control on myMainForm, but not the subform itself.
Try instead:
Forms!myMainForm!mySubForm.Form.Requery
(note: I'm not 100% sure this will solve the issue)
I have a really frustrating problem. Basically I have a mainForm with 3-4 subForms all in datasheet view. What is a generic way to REMOVE focus from subForm after a record is selected and set it to a control on mainForm?
I tried:
OnCurrent Event:
Me.Parent.Form.SetFocus
Me.Parent.[Control].SetFocus
and it works half the time. The problem is, however, when user selects the record by clicking into some field in the subForm. Then the highlightedfields are either A) the field in the subForm, B) the field in the mainForm. Decided seemingly at random.
How do I CANCEL/REMOVE the focus from the subForm completely before setting the new focus elsewhere?
That would be to move focus to a control on the parent form:
Me.Parent!SomeControl.SetFocus
A workaround for this peculiar problem that solved it for me in the end was to make the field in the subForm look like a hyperlink (ie. user can "click" on it).
Then make an OnClick Event which sets the correct focus, that is:
Public Sub [Field]_Click()
On Error GoTo Goto_Err
'some other code
Me.Parent.[Control].SetFocus
Goto_Exit:
Exit Sub
Goto_Err:
MsgBox Error$
Resume Goto_Exit
End Sub
This workaround is not ideal as the user has to click the field itself, rather than simply move to an another record by pressing up/down arrow.
SO I have a subform, that simply has one chart object on it. Its small, and this is the only purpose of this sub. Then I have about 10 forms that each have a sub windows with this form as it's child. I use a UNION query to show the current balance of 10 accounts on each form with this chart for comparative purposes. Everything works fine except for one small thing...
when you open any of these forms, you have to take your mouse over to the actual sub window and click inside of it to get the chart to show. once you do it works fine, on any and all forms, but this same issue if recurring on all these forms as well, so I am sure I am missing something here??
Any ideas about this one?
thanks
Justin
I think you can work this out by not using a subform, but rather a chart control directly inserted in the form. I know it can be a headache to design a chart control in every form, but by doing it, you can control directly the data source of the chart independently from any other form.
Example:
I will suppose that you need to update the chart after updating a text box (txtExample).
You can alter the data source of the control usint the afterUpdate event:
Private Sub txtExample_AfterUpdate()
chart1.RowSource = "SELECT ... FROM ..."
chart1.Requery
End Sub
The RowSource property of the chart object will be altered and updated every time the value of the text box is updated.
Hope this works for you
I have looked around for this problem and found that me.graph1.requery doesn't help in my 2003 version. I did try in desperation this: docmd.requery (Graph1) that crashes but when you put on error resume next it does show the graph everytime! True Microsoft style I guess to fix it with another buggy thing.