Sub form

whojstall11

Registered User.
Local time
Today, 02:49
Joined
Sep 7, 2011
Messages
94
Im trying to figure out how to have my subform refresh its self when I press button. I dont know how to find the name of my sub form is my biggest problem. Do you need to see my database?
 
Last edited:
Click on the subform ONCE. That will be the subform control which is what you need to reference.

Why do you need to refresh anyway?
 
ok but now im using an me.requery that seems to work. But before it saves it deletes the data i want to enter. I have it linked to an click button this is the order i have the code in.
autofill code
save
me.requery

but it doesnt save just deletes my information
 
Why don't you have the subform linked to the parent form? Access will handle your save routine for you.
 
it is but im entering infomation into it from my subform and when i click my button i want it to do my first line of code then save it then requery
Code:
Private Sub CmdUpdate_Click()
DoCmd.SetWarnings False
DoCmd.RunSQL "Update [Order] SET [Order].[CER Number] = '" & Me.[CER Number] & "' WHERE [Order].[PO Number] = " & Me.[PO Number] & ""
DoCmd.RunSQL "UPDATE [Order] SET [Order].[CER Description] = '" & Me.[CER Description] & "' WHERE [Order].[PO Number] = " & Me.[PO Number] & ""
 
DoCmd.RunSQL "UPDATE [Order] SET [Order].[CER Link] = '" & Me.[CER Link] & "' WHERE [Order].[PO Number] = " & Me.[PO Number] & ""
DoCmd.RunSQL "UPDATE [Order] SET [Order].[Quantity] = " & Me.[Quantity] & " WHERE [Order].[PO Number] = " & Me.[PO Number] & ""
DoCmd.RunSQL "UPDATE [Order] SET [Order].[BU Purchased For] = '" & Me.[BU Purchased For] & "' WHERE [Order].[PO Number] = " & Me.[PO Number] & ""
DoCmd.RunSQL "UPDATE [Order] SET [Order].[Date Ordered] = '" & Me.[Date Ordered] & "' WHERE [Order].[PO Number] = " & Me.[PO Number] & ""
DoCmd.RunSQL "UPDATE [Order] SET [Order].[Received] = '" & Me.[Received] & "' WHERE [Order].[PO Number] = " & Me.[PO Number] & ""
DoCmd.RunSQL "UPDATE [Order] SET [Order].[Date Received] = '" & Me.[Date Received] & "' WHERE [Order].[PO Number] = " & Me.[PO Number] & ""
If Received = True Then
    Dim notesdb As Object
    Dim notesdoc As Object
    Dim notesrtf As Object
    Dim notessession As Object
    Dim strEmail As String
    Dim strCopy As String
    Dim strBCC As String
    Dim i As Integer
 
    Set notessession = CreateObject("Notes.Notessession")
    Set notesdb = notessession.GetDatabase("", "")
    Call notesdb.openmail
    Set notesdoc = notesdb.CreateDocument
    Call notesdoc.ReplaceItemValue("Email Test", "Subject" & Date)
    Set notesrtf = notesdoc.CreateRichTextItem("body")
    Call notesrtf.AppendText("ME.[PO Number] has been received.")
    strEmail = "Me.[Email]"
    strCopy = ""
    strBCC = ""
    notesdoc.SendTo = strEmail
    notesdoc.CopyTo = strCopy
    notesdoc.BlindCopyTo = strBCC
    Call notesdoc.Save(True, False)
    notesdoc.SaveMessageOnSend = True
    Call notesdoc.Send(False, strEmail)
    Set notessession = Nothing
Else
End If
On Error GoTo CmdUpdate_Click_Err
    ' _AXL:<?xml version="1.0" encoding="UTF-16" standalone="no"?>
    ' <UserInterfaceMacro For="AddSoft" Event="OnClick" xmlns="[URL]http://schemas.microsoft.com/office/accessservices/2009/11/application[/URL]" xmlns:a="[URL]http://schemas.microsoft.com/office/accessservices/20[/URL]
    ' _AXL:09/11/forms"><Statements><Action Name="SaveRecord"/><Action Name="OpenForm"><Argument Name="FormName">Software Order Form 2</Argument><Argument Name="WhereCondition">="[PO Number]=" & [PO Number]</Argument></Action></Statements></UserInterfaceM
    ' _AXL:acro>
    On Error Resume Next
    DoCmd.RunCommand acCmdSaveRecord
    If (MacroError <> 0) Then
        Beep
        MsgBox MacroError.Description, vbOKOnly, ""
    End If
 
CmdUpdate_Click_Exit:
    Exit Sub
CmdUpdate_Click_Err:
    MsgBox Error$
    Resume CmdUpdate_Click_Exit
Me.Requery
 
End Sub
 
Last edited:
Be careful what you post. You might want to edit your post and remove the e-mail addresses included in the code.

Upload a sample db so I can see it in action. Also briefly describe the steps.
 
I fixed it i put me.requery in my docmd.runcommand but dont go anywhere im going have more questions lol
 
I will stay put at work until 10 p.m. just so I can answer ALL your questions ;) :p lol
 

Users who are viewing this thread

Back
Top Bottom