PC Review


Reply
Thread Tools Rate Thread

command code

 
 
=?Utf-8?B?QW1hdGV1cg==?=
Guest
Posts: n/a
 
      24th May 2007
I am using a command button to open a form in a mainform:

Me.[dummy].SourceObject = “billshelp”

I would like that the “billshelp” Form is showing the data only based on the
clientnumber from the main form where it is opening in.
Can someone help me with the coding?
Thanks
Klaus

 
Reply With Quote
 
 
 
 
=?Utf-8?B?V2F5bmUtSS1N?=
Guest
Posts: n/a
 
      24th May 2007
Private Sub ButtonName_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "billshelp"
stLinkCriteria = "[clientnumber]=" & Me![clientnumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub




--
Wayne
Manchester, England.



"Amateur" wrote:

> I am using a command button to open a form in a mainform:
>
> Me.[dummy].SourceObject = “billshelp”
>
> I would like that the “billshelp” Form is showing the data only based on the
> clientnumber from the main form where it is opening in.
> Can someone help me with the coding?
> Thanks
> Klaus
>

 
Reply With Quote
 
=?Utf-8?B?TWF1cmljZQ==?=
Guest
Posts: n/a
 
      24th May 2007
Why don't you try something like:

(could be on the on acitivate of the subform)
Dim sSQL as String
Dim iClient as integer ->assuming number

iclient=me.parent.clientnumber

sSQL="Select * From [your tablename here] Where clientnumber= " & iclient
(if it's a textfield you should place quotes like this:

Where clientnumber ='" & iclient & "'"

Then append the sSQL as your sourceobject like this

Me.[dummy].SourceObject = sSQL

If you have navigationbuttons you must realize that code has to be
implemented on the on current of the form as well (hitting perfomance like
.....)

--
Maurice Ausum


"Amateur" wrote:

> I am using a command button to open a form in a mainform:
>
> Me.[dummy].SourceObject = “billshelp”
>
> I would like that the “billshelp” Form is showing the data only based on the
> clientnumber from the main form where it is opening in.
> Can someone help me with the coding?
> Thanks
> Klaus
>

 
Reply With Quote
 
=?Utf-8?B?QW1hdGV1cg==?=
Guest
Posts: n/a
 
      24th May 2007
Dear Wayne
thanks for the code - but with this code my "billshelp" Form is opening
seperate and not in the main form. Somehow I have to merge your code with:
Me.[dummy].SourceObject = “billshelp”.
Do you have any idea how to do that?
Thanks
Klaus

"Wayne-I-M" wrote:

> Private Sub ButtonName_Click()
> Dim stDocName As String
> Dim stLinkCriteria As String
> stDocName = "billshelp"
> stLinkCriteria = "[clientnumber]=" & Me![clientnumber]
> DoCmd.OpenForm stDocName, , , stLinkCriteria
> End Sub
>
>
>
>
> --
> Wayne
> Manchester, England.
>
>
>
> "Amateur" wrote:
>
> > I am using a command button to open a form in a mainform:
> >
> > Me.[dummy].SourceObject = “billshelp”
> >
> > I would like that the “billshelp” Form is showing the data only based on the
> > clientnumber from the main form where it is opening in.
> > Can someone help me with the coding?
> > Thanks
> > Klaus
> >

 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      24th May 2007
In news:C5686003-9B36-41D1-A705-(E-Mail Removed),
Amateur <(E-Mail Removed)> wrote:
> I am using a command button to open a form in a mainform:
>
> Me.[dummy].SourceObject = "billshelp"
>
> I would like that the "billshelp" Form is showing the data only based
> on the clientnumber from the main form where it is opening in.
> Can someone help me with the coding?


So this code is executing on the main form, and "dummy" is the name of a
subform control on that form? You can establish the filtering you want
via the Link Master Fields and Link Child Fields properties of the
subform control.

If the subform is always going to be filtered by clientnumber, you would
normally set those properties at design time. In that case, setting the
subform's SourceObject property at run time defers the loading of the
subform, but doesn't do anything else.

If you're using the same [dummy] subform control to display different
subforms, and they aren't all linked by clientnumber, then you have to
assign values to the Link Master and Child Fields properties at the time
you assign the SourceObject. You might do this:

With Me![dummy]
On Error Resume Next ' temporarily ignore errors
.LinkMasterFields = "clientnumber"
.LinkChildFields = "clientnumber"
' restore original error-handler
On Error Go To YourErrorHandlerCode
.SourceObject = "billshelp"
End With

The reason for temporarily disabling error-handling is that I have found
that Access raises an error if, in the process of setting the Link
Master/Child fields properties, I momentarily have a different number of
fields listed in one of the properties from the number of fields listed
in the other property. However, by the time I'm done setting both
properties, all is well again.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


 
Reply With Quote
 
=?Utf-8?B?RGFsZSBGeWU=?=
Guest
Posts: n/a
 
      24th May 2007
If form "billshelp" will only open as a subform, or when your main form is
open, you could modify its underlying record source (query) so that the
ClientNumber uses the main forms ClientNumber field. Your Record source
would look something like:

SELECT * FROM yourTable
WHERE [ClientNumber] = Forms!frm_MainForm.txt_ClientNumber

HTH
Dale

--
Email address is not valid.
Please reply to newsgroup only.


"Amateur" wrote:

> I am using a command button to open a form in a mainform:
>
> Me.[dummy].SourceObject = “billshelp”
>
> I would like that the “billshelp” Form is showing the data only based on the
> clientnumber from the main form where it is opening in.
> Can someone help me with the coding?
> Thanks
> Klaus
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command code Very Basic User Microsoft Excel Misc 2 30th Jul 2009 05:58 PM
command code ( GOTO command) in formula calan Microsoft Excel New Users 1 11th Jun 2009 09:44 AM
Command button VB code =?Utf-8?B?QW1hdGV1cg==?= Microsoft Access 9 10th Oct 2007 07:24 PM
How Do I Specify the Code to Run on a Switchboard Run Code Command =?Utf-8?B?QW15IEJhZ2dvdHQ=?= Microsoft Access 4 16th May 2005 06:00 PM
Executing C code from a Command Button's code =?Utf-8?B?bmpj?= Microsoft Word Document Management 1 19th Apr 2004 10:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:50 PM.