Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autoexpand subform 1

Status
Not open for further replies.

weckels

MIS
Joined
May 9, 2002
Messages
26
Location
US
I have a form in datasheet mode and its subform in datasheet mode also. When I hit enter after entering data in the last field of the main form I want the subform to automatically expand (now I have to click the '+' sign at the left of the record to expand the subform) and I want focus to shift to the first field in the subform. I've tried "sendkeys " ^+{down}" and the subform expands but the focus is sent to the first field of the next record in the main form. I'm sure there is a cleaner way to approach this that actually works!
Thank you.
 
Unfortunately, the DATASHEET mode of forms leaves a great deal to be desired, among which is the ability to capture events like ON EXIT and such. Try changing your form view to CONTINUOUS forms instead - it looks very much similar, and you can do a bit more with it.

From as far as I can see, there is no way to force the behavior you desire using datasheets.

Jim How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
Thanks Jim but I get a message that says I can't view a form as continuous if it contains a subform, which it does. Do you suppose there is code that mimics clicking on the "+" to the left of the record? Thank you for your time.

Will
 
Ah yes, sorry, I didn't read/comprehend your post completely. You can not have a Sub form IN a continuous form.

HOWEVER, you can have a CONTINUOUS (sub)form and another CONTINOUS (sub)form IN a plain ol' unbound form. It's a bit dicey to keep them synchronized, but I have heard of it being done.

What I might also try to do is build a query that 'flattens' the hierarchy into a single level and displays in either a datasheet or continuous form.

I know of no 'code' per se that mimics the 'subdatasheet' guy you speak of.

Rather than fight with Access to get it to do what you want it to, try using its' strengths to create a new solution to your problem.

Think query. It make take a few steps, but I tend to think that 'flattening' your hierarchy might be the best way to go. I have no concrete example, just a hunch.

Good luck.

Jim



How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
There is a property called Me.SubDataSheetExpanded

It will keep always subdatasheet expanded

You can set and reset atrequired times


May be in Form_afterUpdate Event

Set the boolean value of Me.NewRecord inot some form variable in Form_BeforeInsert

Check the boolean in Form_afterUpdate and Set Me.SubDataSheetExpanded to true and Set Focus to SubForm

Then in Form_Current Make Me.SubDataSheetExpanded to False


Option Compare Database
Public fNewRecord As Boolean

Private Sub Form_AfterUpdate()
If fNewRecord Then
Me.SubdatasheetExpanded = True
Me.Child4.SetFocus
End If
fNewRecord = False
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
fNewRecord = NewRecord
End Sub



Private Sub Form_Current()
Me.SubdatasheetExpanded = False
End Sub
 
Excellent job, Rajeessh - I don't work in datasheets very often, and hadn't thought to actually check out the new properties in A2K (just recently migrated some of my stuff to it from A97)

Star for you!

Jim How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
Thanks to both of you for your help. I think the suggestion Rajeessh has will work just fine. Thanks a lot for your time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top