Problem updating main form

bskowtexas

Registered User.
Local time
Today, 12:44
Joined
Sep 10, 2002
Messages
11
Hey guys, this is a tough one because i'm not super proficient at VBA.

I have a parent form with check out information and a subform where the user can scan in items in a one-to-many relationship. Usually, my users forget the parent form and just start scanning stuff in. That's ok though, because i have it set up to where when someone scans something into the subform the parent information automatically fills.

Problem is...although the parent form fills and matches with my child data, it won't allow record additions because there is "no related record." I realize that this is because the parent form hasn't updated following the changes, but every thing i try to do to get the parent to update fails. If i try to requery it, it says that the parent form is not open. Further, if i try to shift the focus to the parent form, it says the form isn't open. Any ideas why?

Keep in mind, I don't know visual basic very well, so if you throw code my way, dumb it down for me.

thanks
-bskow
 
Sir, you'll have to be more specific. Merely saving the record isn't working in this situation. In fact, it says that it can't save a record because there is no matching data in the parent form. If you're talking about saving the record on the parent form, give me a little help please. How do i specifically save the record? Everytime i try to shift focus to the parent form, i get an error message telling me it's not even open.
 
Gotcha. Ok here's where i'm at. In the On Enter event of the subform, I have a macro to set the values on the main form. This should be cool, because it is technically before anything has been entered on the subform. My problem is getting back to the main form (so it can save) and then back to the subform again (so the user can enter data). Is this even possible?
 
First of all, I'm using macros because i don't know VBA. They suck, i know, but they're all i've got. Secondly, what i'm trying to do is really simple.

1) user accidentally enters subform before keying in mainform data.
2) values in mainform are set automatically using the subform's On Enter event.
3) BEFORE data is entered into the subform, mainform updates.
4) user enters subform data, linked to updated parent data.

I need help with step 3. Thanks for your patience Pat.

-bskow
 
Thanks for the help Pat, but I figured it out another way. I made a function that set the values for the parent form and used

Me.Parent.txtDateDue.SetFocus

then i called the function in a macro in the OnEnter event for the subform under the condition that the parent data is null.

Thanks for the help,
bskow
 
Problem Updating MainForm - Revisited...

Hi Guys,

I had essentially the same situation, and used this solution too. Then, after having it in production for a while, and getting user feedback, I realized it is easier for your users if you can leave out the "MsgBox" code and just immediately refocus them where they need to be.

Code:
Private Sub Form_BeforeInsert(Cancel As Integer)

On Error GoTo Err_Form_BeforeInsert
If IsNull(Me.Parent.OrderID) Then
    Cancel = True
    Me.Undo
    ' MsgBox "You must enter top level Order data before entering Order details."
    Me.Parent.OrderDate.SetFocus
End If
Exit_Form_BeforeInsert:
    Exit Sub

Err_Form_BeforeInsert:
     MsgBox Err.Number & " - " & Err.Description
    Resume Exit_Form_BeforeInsert
End Sub
 
from the subform try:

Parent.Dirty = False

This forces the parent form to save
 
Last edited:
Why are we posting a response to a 3 month old post which was a response to a 4 year old post?
 
Sorry Bob,
I didn't mean to break any protocols.

I came across this thread but it didn't have the answer. So when I found the answer, I posted it here thinking it could help the original posters.

If I'm not supposed to do this I won't do it anymore.
:)

Evan
 

Users who are viewing this thread

Back
Top Bottom