If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Force user to click on Main Form First??
Hello -
Is it possible to force a user to select a field in the Main form prior to inputing any info into the subforms? Or is it possible for the Main form to assign and ID to the record when a user begins filling out the subform? Thanks - Lee - -- Message posted via http://www.accessmonster.com |
#2
|
|||
|
|||
Force user to click on Main Form First??
One way is to use the Before Insert event of the subform.
Private Sub Form_BeforeInsert(Cancel As Integer) If Me.Parent.NewRecord Then Cancel = True MsgBox "Please enter the main form record first." End If End Sub Another way is to hide or disable the subform and then use the BeforeInsert event of the main form to show/enable it. Then it becomes available as soon as they type the first character into the main form. You also need to test the NewRecord property in the Current event of the main form so you can then disable/hide the subform again. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia "TheLee via AccessMonster.com" u59624@uwe wrote in message news:a752202dda107@uwe... Hello - Is it possible to force a user to select a field in the Main form prior to inputing any info into the subforms? Or is it possible for the Main form to assign and ID to the record when a user begins filling out the subform? Thanks - Lee - -- Message posted via http://www.accessmonster.com |
#3
|
|||
|
|||
Force user to click on Main Form First??
Hi Jeanette,
Will this also work if it is a tabbed subform? Sorry, I should have mentioned this in my original post. I don't have any experience using code in the db. I messed around with it for a bit but couldn't get it to work. Thanks - Lee Jeanette Cunningham wrote: One way is to use the Before Insert event of the subform. Private Sub Form_BeforeInsert(Cancel As Integer) If Me.Parent.NewRecord Then Cancel = True MsgBox "Please enter the main form record first." End If End Sub Another way is to hide or disable the subform and then use the BeforeInsert event of the main form to show/enable it. Then it becomes available as soon as they type the first character into the main form. You also need to test the NewRecord property in the Current event of the main form so you can then disable/hide the subform again. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia Hello - Is it possible to force a user to select a field in the Main form prior to [quoted text clipped - 4 lines] Thanks - Lee - -- Message posted via http://www.accessmonster.com |
#4
|
|||
|
|||
Force user to click on Main Form First??
It should.
To use the code, you would open the subform in design view. On the subform's property sheet, on the Events tab, find the event called Before Insert On the same as that event, click the button with 3 dots on in (it's on the right) Access will open the code window Copy and paste this code into the code window 'start of code ------------- Option Compare Database Option Explicit Private Sub Form_BeforeInsert(Cancel As Integer) If Me.Parent.NewRecord Then Cancel = True MsgBox "Please enter the main form record first." End If End Sub 'end of code ------------------- Notes: Now check the very first lines of code at the top of the code window. If you see Option Compare Database more than once, delete the copies until there is only one occurrence of Option Compare Database Do the same for Option Explicit Now on the menu at top of the screen, choose Debug, then compile. Save and close the code window. Save and close the form. Test the form to see how the code works. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia "TheLee via AccessMonster.com" u59624@uwe wrote in message news:a7536e203cdfc@uwe... Hi Jeanette, Will this also work if it is a tabbed subform? Sorry, I should have mentioned this in my original post. I don't have any experience using code in the db. I messed around with it for a bit but couldn't get it to work. Thanks - Lee Jeanette Cunningham wrote: One way is to use the Before Insert event of the subform. Private Sub Form_BeforeInsert(Cancel As Integer) If Me.Parent.NewRecord Then Cancel = True MsgBox "Please enter the main form record first." End If End Sub Another way is to hide or disable the subform and then use the BeforeInsert event of the main form to show/enable it. Then it becomes available as soon as they type the first character into the main form. You also need to test the NewRecord property in the Current event of the main form so you can then disable/hide the subform again. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia Hello - Is it possible to force a user to select a field in the Main form prior to [quoted text clipped - 4 lines] Thanks - Lee - -- Message posted via http://www.accessmonster.com |
#5
|
|||
|
|||
Force user to click on Main Form First??
Hi Jeanette -
Thank you very much for the info. Unfortunately it looks like I cannot do this on the Tabbed Form. It does not have a Before Insert event. The main form does though. The issue is a user can fill out the subform prior to making an entry in the main form. Then when they go back and enter info in the main form it wipes out the info they entered in the subform. Maybe there is a way to force the main form to assign an OrderID when the user clicks on the tabbed form?? Thanks - Lee Jeanette Cunningham wrote: It should. To use the code, you would open the subform in design view. On the subform's property sheet, on the Events tab, find the event called Before Insert On the same as that event, click the button with 3 dots on in (it's on the right) Access will open the code window Copy and paste this code into the code window 'start of code ------------- Option Compare Database Option Explicit Private Sub Form_BeforeInsert(Cancel As Integer) If Me.Parent.NewRecord Then Cancel = True MsgBox "Please enter the main form record first." End If End Sub 'end of code ------------------- Notes: Now check the very first lines of code at the top of the code window. If you see Option Compare Database more than once, delete the copies until there is only one occurrence of Option Compare Database Do the same for Option Explicit Now on the menu at top of the screen, choose Debug, then compile. Save and close the code window. Save and close the form. Test the form to see how the code works. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia Hi Jeanette, Will this also work if it is a tabbed subform? Sorry, I should have [quoted text clipped - 32 lines] Thanks - Lee - -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201005/1 |
#6
|
|||
|
|||
Force user to click on Main Form First??
Look on the subform for the Before Insert event.
The subform is inside the subform control on the tab control. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia "TheLee via AccessMonster.com" u59624@uwe wrote in message news:a78269138ba14@uwe... Hi Jeanette - Thank you very much for the info. Unfortunately it looks like I cannot do this on the Tabbed Form. It does not have a Before Insert event. The main form does though. The issue is a user can fill out the subform prior to making an entry in the main form. Then when they go back and enter info in the main form it wipes out the info they entered in the subform. Maybe there is a way to force the main form to assign an OrderID when the user clicks on the tabbed form?? Thanks - Lee Jeanette Cunningham wrote: It should. To use the code, you would open the subform in design view. On the subform's property sheet, on the Events tab, find the event called Before Insert On the same as that event, click the button with 3 dots on in (it's on the right) Access will open the code window Copy and paste this code into the code window 'start of code ------------- Option Compare Database Option Explicit Private Sub Form_BeforeInsert(Cancel As Integer) If Me.Parent.NewRecord Then Cancel = True MsgBox "Please enter the main form record first." End If End Sub 'end of code ------------------- Notes: Now check the very first lines of code at the top of the code window. If you see Option Compare Database more than once, delete the copies until there is only one occurrence of Option Compare Database Do the same for Option Explicit Now on the menu at top of the screen, choose Debug, then compile. Save and close the code window. Save and close the form. Test the form to see how the code works. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia Hi Jeanette, Will this also work if it is a tabbed subform? Sorry, I should have [quoted text clipped - 32 lines] Thanks - Lee - -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/201005/1 |
Thread Tools | |
Display Modes | |
|
|