John V
Thanks, John B
--- In MS_Access_Professionals@yahoogroups.com, "John Viescas" <john@...> wrote:
>
> John-
>
> The Wizard-generated code is marginal at best. Here's what I would do:
>
> Private Sub Open_Customer_Contacts_Form_Click()
> On Error GoTo Err_Open_Customer_Contacts_Form_Click
>
> ' Open the form filtered but hidden
> DoCmd.OpenForm "Customer Contacts", _
> WhereCondition:="[CustomerID]=" & Me![CustomerID], _
> WindowMode:=acHidden
> ' Test to see if there are any records
> If Forms![Customer Contacts].Recordset.RecordCount = 0 Then
> ' Tell user and close the form
> MsgBox "There are no contacts for this customer.", vbInformation
> DoCmd.Close acForm, "Customer Contacts"
> Else
> ' Form has data - unhide it
> Forms![Customer Contacts].Visible = True
> End If
>
> Exit_Open_Customer_Contacts_Form_Click:
> Exit Sub
>
> Err_Open_Customer_Contacts_Form_Click:
> MsgBox Err.Description
> Resume Exit_Open_Customer_Contacts_Form_Click
>
> End Sub
>
>
> John Viescas, author
> Microsoft Office Access 2010 Inside Out
> Microsoft Office Access 2007 Inside Out
> Building Microsoft Access Applications
> Microsoft Office Access 2003 Inside Out
> SQL Queries for Mere Mortals
> http://www.viescas.com/
> (Paris, France)
>
>
>
> -----Original Message-----
> From: MS_Access_Professionals@yahoogroups.com
> [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of
> jbloomstine@...
> Sent: Wednesday, August 24, 2011 5:43 AM
> To: MS_Access_Professionals@yahoogroups.com
> Subject: Re: [MS_AccessPros] VBA help needed for command button
>
> Hi John V,
>
> Here is the code:
> Private Sub Open_Customer_Contacts_Form_Click()
> On Error GoTo Err_Open_Customer_Contacts_Form_Click
>
> Dim stDocName As String
> Dim stLinkCriteria As String
>
> stDocName = "Customer Contacts"
>
> stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
> DoCmd.OpenForm stDocName, , , stLinkCriteria
>
> Exit_Open_Customer_Contacts_Form_Click:
> Exit Sub
>
> Err_Open_Customer_Contacts_Form_Click:
> MsgBox Err.Description
> Resume Exit_Open_Customer_Contacts_Form_Click
>
> End Sub
>
> Would you have a different code than what Duane Hookom suggested?
>
>
> Thanks, John Bloomstine
>
>
> --- In MS_Access_Professionals@yahoogroups.com, "John Viescas"
> <john@> wrote:
> >
> > Dear jblookstine (name?)-
> >
> > Rather than post your entire database, all you need to do is post the
> code that
> > you currently have behind the command button.
> >
> > John Viescas, author
> > Microsoft Office Access 2010 Inside Out
> > Microsoft Office Access 2007 Inside Out
> > Building Microsoft Access Applications
> > Microsoft Office Access 2003 Inside Out
> > SQL Queries for Mere Mortals
> > http://www.viescas.com/
> > (Paris, France)
> >
> >
> > -----Original Message-----
> > From: MS_Access_Professionals@yahoogroups.com
> > [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of
> > jbloomstine@
> > Sent: Monday, August 22, 2011 12:53 AM
> > To: MS_Access_Professionals@yahoogroups.com
> > Subject: [MS_AccessPros] VBA help needed for command button
> >
> > I have not being able to figure out how to revise the VBA code for my
> 08_11_11
> > FEP_DB Access 2003 database. The Customers form has a command button
> titled
> > "Open Contacts for this Customer." When it is clicked, it displays
> the matching
> > records for the contacts that have been made for a client.
> >
> > If a customer does not have any Customer Contacts entered and the
> command button
> > is clicked, it displays a blank Customer Contacts form. I need to
> have the
> > coding revised so it displays a message box that states there are not
> any
> > Customer Contacts for this customer. I also don't want the Customer
> Contacts
> > form to open when there are not any matching records in that form.
> >
> > I am hoping to be able to post my database.
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
Kamis, 25 Agustus 2011
[MS_AccessPros] Re: VBA help needed for command button
__._,_.___
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar