Senin, 13 Februari 2017

Re: [MS_AccessPros] VBA for Add New Record on 2-Click

 

David-


You can add a Totals row to any Datasheet:



John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Feb 13, 2017, at 9:06 AM, Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



David,
Congrats and exploring and trying something new! 

If you open a form acDialog, the code will stop running until the form frmSegmentsAndFeatures is closed. 

Since you seem to be comfortable with research on your own, check out "OpenArgs" which allows you to send values to the form being opened. Send the values you want to set and then have code in the On Open event of frmSegmentsAndFeatures which sets the default values of the controls.

Regards,
Duane



From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of david.pratt@outlook.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Sunday, February 12, 2017 11:10 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] VBA for Add New Record on 2-Click
 


I am reading stuff and looking at internet stuff and watching YouTube videos trying to learn and get new ideas.  I recently watched a YouTube video about Project Management.  IN that video he used a form that I am trying to reproduce.  the video talks about the information in the form, but not how to create the form, so I am trying on my own to reproduce the form as a learning method.

The form is unbound, has two combo boxes at the top; one for Company and one for Projects, both unbound, and has four list boxes.  The form name is frmMainProjMgr.  So at the top I have cboSelectCompany and cboSelectProject, with cboSelectProject query criteria based on the value of cboSelectCompany.  No problem.

Under the two combo's are several list boxes.  My first list box is based on a query of ProjectSegments table, which includes the foreign key ProjectID (with combo cboProjectID). The form's query criteria is based on the value of the unbound combo, cboSelectProject.  I am trying to add new records to this table of ProjectSegments.  I want to 2-click on the list box and bring up a form to create a new ProjectSegments record.  The name of that form is frmSegmentsAndFeatures.

Also, when I bring up the form frmSegmentsAndFeatures to create a new ProjectSegment record, I would like the value in ProjectSegment.ProjectID to default to the value of cboSelectProject and I would like to set the focus on that form to the control named txtSegmentNumber.  My VBA is not working and I need help please.  

Here is what I have on the 2-click event for the list box:

Private Sub lstProjectSegments_DblClick(Cancel As Integer)
On Error GoTo lstProjectSegments_Click_Err
    On Error Resume Next
  
    DoCmd.OpenForm "frmSegmentsAndFeatures", acNormal, , , acFormAdd, acDialog
    Forms!frmSegmentsAndFeatures.cboProjectID = Forms!frmMainProjMgr.cboSelectProjectID
    Forms!frmSegmentsAndFeatures!txtSegmentNumber.SetFocus
    If (Error <> 0) Then
        Beep
        MsgBox Error.Description, vbOKOnly, ""
    End If

lstProjectSegments_Click_Exit:
    Exit Sub
lstProjectSegments_Click_Err:
    MsgBox Error$
    Resume lstProjectSegments_Click_Exit
End Sub






__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar