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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating field in subform from main form 1

Status
Not open for further replies.

lppa

Technical User
Apr 5, 2004
26
0
0
US

I have a form frmInvoice with Subform frmInvoiceMemos related by invoiceID field. After populating fields “ScheduledDate” and “ScheduledTime” of the main form, I need new record in subform as: “09/13/2005 10:23AM: Appointment scheduled for 09/15/2005, 1-5PM”
This is an approach I took, but it is not working:

Private Sub ScheduledTime_LostFocus()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmInvoiceMemos"
stLinkCriteria = "[InvoiceID]=" & Me![InvoiceID]

DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd
Forms!frmInvoiceMemos.Memo = Me.ScheduledDate
Forms!frmInvoiceMemos.Memo = Me.ScheduledTime


DoCmd.Close

End Sub

Thanks
 
Here is something you can able to do...
Code:
Private Sub ScheduledDate_AfterUpdate()
Me.frmInvoiceMemos.Form.memo = Me.ScheduledDate & " " & Me.ScheduledTime
End Sub

Private Sub ScheduledTime_BeforeUpdate(Cancel As Integer)
Me.frmInvoiceMemos.Form.memo = Me.ScheduledDate & " " & Me.ScheduledTime
End Sub
But I don't understand why to create a new record everytime you change/loose focus the schedule time

________________________________________________________
Zameer Abdulla
Help to find Missing people
You may be the boss' pet; but you are still an animal
 
Hi Zameer,

Thanks a lot, its inserts date and time in first record perfectly. The reason I need to create a new memo record every time a new appointment scheduled is that some times more then one appointment needed to complete the job and we need to keep track of each appointment. There for every time new appointment is created, new line in Subform frmInvoiceMemos (subform form displayed in datasheet view) need to be created as: “09/13/2005 10:23AM: Appointment scheduled for 09/15/2005, 1-5PM” where current date/time stamp stays first, followed by scheduled date/time. I have code for current date/time stamp:

Code:
If Me![Memo] = " " Or Me![Memo] = "" Or IsNull(Me![Memo]) Then
    Me![Memo] = "" & Format(DATE, "Short Date") & " " & Format(Time(), "Medium Time") & "    "
    Me.Refresh
    
End If
    Me![Memo].SelLength = 0
    Me![Memo].SelStart = Len(Me![Memo]) + 1

But I can’t create new record every time and put all of that together.
Can you help me out.

Thanks again.
 
Create a command button on the Mainform(frmInvoices) and add the code below.
Code:
Private Sub cmdAddNew_Click()
Me.frmInvoiceMemos.SetFocus
    With DoCmd
        .GoToRecord , , acNewRec
    End With
Me.frmInvoiceMemos.Form.Memo = Me.ScheduledDate & " " & Me.ScheduledTime
End Sub
hope this helps

________________________________________________________
Zameer Abdulla
Help to find Missing people
You may be the boss' pet; but you are still an animal
 
Thanks
I put that all together and it works greate:
Code:
Private Sub ScheduledTime_LostFocus()


   
    Dim stDocName As String
    Dim stLinkCriteria As String
    
    Me.frmInvoiceMemos.SetFocus
    With DoCmd
         .GoToRecord , , acNewRec
    
    End With
    Me.frmInvoiceMemos.Form.Memo = "" & Format(Date, "Short Date") & " " & Format(Time(), "Medium Time") & ":" & "   APPOINTMENT SCHEDULED FOR  " & Me.ScheduledDate & " " & Me.ScheduledTime
    Me.frmInvoiceMemos.Form.Memo.SelLength = 0
    Me.frmInvoiceMemos.Form.Memo.SelStart = Len(Me.frmInvoiceMemos.Form.Memo) + 1
    

    
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top