Another Visible/Hidden Form Field Question (1 Viewer)

psyc0tic1

Access Moron
Local time
Today, 15:31
Joined
Jul 10, 2017
Messages
360
@gasman
I wish I could say it's done by some very clever coding but I would be lying.
There is no trickery and indeed no code.
If you look at the tab order for the main form, the subform control precedes the hide subform button so it tabs from subform to that button

@Richard
Sorry I got led astray by your key up code
As stated above, you don't need any code in the last control on your subform.
Remove everything you've done for this issue.
Just make sure the tab order has subform before lab defect textbox and it should tab correctly

Yea I had tried that originally and it actually has the same effect as did with the code... it just blanks the subform fields except for the ones I mentioned earlier and focuses back on the first field of the subform.

I have the tab orders to go through the top main form fields (1 through 5) and it tabs to the subform correctly as it is next in the tab order (6) but it will not tab to the next tab number on the main form (7).

I know it is totally easy to solve this by having everyone use Ctrl+Tab which of course works but I don't expect the users to remember that as I have enough trouble getting them to fill out fields correctly.
 

isladogs

MVP / VIP
Local time
Today, 20:31
Joined
Jan 14, 2017
Messages
18,186
Yea I had tried that originally and it actually has the same effect as did with the code... it just blanks the subform fields except for the ones I mentioned earlier and focuses back on the first field of the subform.

I have the tab orders to go through the top main form fields (1 through 5) and it tabs to the subform correctly as it is next in the tab order (6) but it will not tab to the next tab number on the main form (7).

I know it is totally easy to solve this by having everyone use Ctrl+Tab which of course works but I don't expect the users to remember that as I have enough trouble getting them to fill out fields correctly.

Can you see any difference between your form and mine in this respect because mine definitely works
 

psyc0tic1

Access Moron
Local time
Today, 15:31
Joined
Jul 10, 2017
Messages
360
Can you see any difference between your form and mine in this respect because mine definitely works

I don't... I had went back and looked and the only real difference between your and mine is your subform is in datasheet view and mine is in single form view... well... aside from all the other code behind the main form.

**EDIT**
From what I have read your setup will definitely work for datasheet view but will not work for single form view.
 
Last edited:

psyc0tic1

Access Moron
Local time
Today, 15:31
Joined
Jul 10, 2017
Messages
360
Okay... FYI

This worked on the form when showing the subform that has the 100 fields on it visible and awaiting data: (last control is Part55MinReading1_2)
Code:
Private Sub Part55MinReading1_2_KeyDown(KeyCode As Integer, Shift As Integer)
    If (KeyCode = vbKeyTab And Shift = 0) Then
        KeyCode = 0
        Me.Parent!LabDefectFound.SetFocus
    End If
End Sub

It also worked within the navigation form.

For some reason the code does not work for the other subform that showed only half the fields... trying to determine why. (last control is Part55MinReading1)
Code:
Private Sub Part55MinReading1_KeyDown(KeyCode As Integer, Shift As Integer)
    If (KeyCode = vbKeyTab And Shift = 0) Then
        KeyCode = 0
        Me.Parent!LabDefectFound.SetFocus
    End If
End Sub

The other half of the fields that are also on the first subform are hidden with the tab stop set to "no".

on this one when I tab to the last visible control it skips immediately to the next main form control. strange.
 
Last edited:

psyc0tic1

Access Moron
Local time
Today, 15:31
Joined
Jul 10, 2017
Messages
360
DUH!!!!!

I just realized I used KeyUp on the second one instead of KeyDown.

It doesn't show that in the code up above but somehow it got that way and i got it all sorted out and it works now... all even from within the navigation form.

WooHoo!!
 

isladogs

MVP / VIP
Local time
Today, 20:31
Joined
Jan 14, 2017
Messages
18,186
Excellent. Glad you solved it. :D

I'm not at my computer so haven't tried it yet ... but for the benefit of others still reading this thread, you will have needed to set Key Preview =Yes on the subform for this to work.

BTW you were right that it only worked without code where the subform was a datasheet.

So can this thread be marked solved now?
 

psyc0tic1

Access Moron
Local time
Today, 15:31
Joined
Jul 10, 2017
Messages
360
Excellent. Glad you solved it. :D

I'm not at my computer so haven't tried it yet ... but for the benefit of others still reading this thread, you will have needed to set Key Preview =Yes on the subform for this to work.

BTW you were right that it only worked without code where the subform was a datasheet.

So can this thread be marked solved now?

Strangely enough with Key Preview set to "No" on both subforms they work perfectly.

I was also able to solve the problem with the code checking to see if all fields were filled out by adding the boolean check to the subforms.

Now everything works as desired.

Marking the thread solved.

ridders... again... I can't thank you enough for all fo your help... I have learned a lot in this thread.
 

psyc0tic1

Access Moron
Local time
Today, 15:31
Joined
Jul 10, 2017
Messages
360
I am still going to work on how the forms actually check to see if the part number is related to USB ports or not. It works great even though I know I did it the wrong way but I will get it.

Cheers everyone. I hope this thread helps many more.
 

isladogs

MVP / VIP
Local time
Today, 20:31
Joined
Jan 14, 2017
Messages
18,186
You're very welcome.
I'm amazed it works with Key Preview set to No
The set focus would work but setting the key code to 0 shouldn't do so.

EDIT:
I've now tested it & can confirm it works for me using a single subform with Key Preview set to Yes or No.
The tab is definitely disabled in both cases - tested by removing the set focus line. Very odd!

BUT ....if I edit the value of the final control in the subform & click enter:
a) it tabs to the next subform record if Key Preview = No - which you don't want
b) it moves to the main form control if Key Preview = Yes - which you do want

So I still think you should set Key Preview = Yes
.
 
Last edited:

psyc0tic1

Access Moron
Local time
Today, 15:31
Joined
Jul 10, 2017
Messages
360
I took your advice and changed the subforms key preview to Yes and it still works so all good.
 

Users who are viewing this thread

Top Bottom