Cmd Buttons and Args

D

d9pierce

Hi all,
Before I pull out my last hair on this, I will post this Please Help
on this darn Cmd button issue I am having in hopes of resolving it.

Here is the situation:

I have an Unbound form called "StartUp". This form acts as a
switchboard and only consist of cmd buttons. The Cmd Buttons are as
follows:

Retail Client
SubContractor
Vendor
Mall

I want these to open a form called "Company_Main" which is a bound
form created from a query called "Company_Main_Cities" There are many
different Combo, Txt, and misc... boxes on this form. What I want is
to be able to open this form by clicking one of the above CmdButtons
to a selected txt in a combo box called "CompanyType". Now,
"CompanyType" is a drop down combo box that contain the following
data:

Retail Client
Subcontractor
Vendor
Mall

Now both above Combo and cmd's will have more once I figure this out,
or should I say when We figure this out. but for now this is it.

I want to click Cmd Retail Clients and have the form open showing only
records of Retail Clients. The CompanyType should be filled in "Retail
Clients" and the form should be at this point be filtered. And again
on when Cmd Subcontractors is clicked, this form should open to
Subcontractor and CompanyType should show Subcontractor and so forth
and so on with the rest.

Also, on the form "Company_Main" I need some type of code that when
Retail client or Subcontractor, or Mall is selected from the dropdown
"CompanyType", it makes certain fields in the form visable=True /
Visable=False. This could be on the on current of the form properties.

I would really appriciate any help with this as I am to my wits end
and have tried everything under the sun. Feel free to email me
directly if desired at (e-mail address removed). I check post a lot and if
you need anymore additional information please let me know. I would
also be willing to email over my db. It is very small at the moment so
no big files.

Thans so much!

dave
 
G

Guest

Dave,

First, if you already have four command buttons on your form, one for each
company type, then you would not also need a combo box. Each of the command
buttons would take care of handling your issue.

Let's take one company type for an example:

Place the following code in Click event of the "Retail Client" button

DoCmd.OpenForm "Company_Main", acNormal, , "CompanyType = ""Retail Client"""

This will cause the Company_Main form to open and be filtered to show only
those records where the company type is Retail Client.

To make the other buttons work, just change "Retail Client" to the
corresponding company type for each button.
 
D

d9pierce

Dave,

First, if you already have four command buttons on your form, one for each
company type, then you would not also need a combo box. Each of the command
buttons would take care of handling your issue.

Let's take one company type for an example:

Place the following code in Click event of the "Retail Client" button

DoCmd.OpenForm "Company_Main", acNormal, , "CompanyType = ""Retail Client"""

This will cause the Company_Main form to open and be filtered to show only
those records where the company type is Retail Client.

To make the other buttons work, just change "Retail Client" to the
corresponding company type for each button.
--
HTH

Mr B
















- Show quoted text -

Hi Mr. B,
thanks, I tried that and it didnt work. It left me with an error that
form action was canceled. Not sure why but Itried that at the begining
of all of this and it just doesnt work and I am just lost. If you have
any other ideas, would be greatful.
thanks,
Dave
 
D

d9pierce

Dave,

First, if you already have four command buttons on your form, one for each
company type, then you would not also need a combo box. Each of the command
buttons would take care of handling your issue.

Let's take one company type for an example:

Place the following code in Click event of the "Retail Client" button

DoCmd.OpenForm "Company_Main", acNormal, , "CompanyType = ""Retail Client"""

This will cause the Company_Main form to open and be filtered to show only
those records where the company type is Retail Client.

To make the other buttons work, just change "Retail Client" to the
corresponding company type for each button.
--
HTH

Mr B
















- Show quoted text -

Hi again Mr B,
I do need the combo box on the "Main_Form as that is where I add new
records to this form, view and edit records on this form, and so
forth... so I do need this combo look up box. This is what also
determins what companies are Retail clients, subcontractors, and so
on...

Thanks,
Dave
 
G

Guest

Dave,

I was not suggesting that you do not need the combo boxes on the main form.
I was only suggesting that you do not need one on your startup form.

The code that I provided should have worked. Are you sure that you do not
have some other issue going on. Do you have any other code that might be
causing a problem? Do you compile your code before attempting to run it?

It is possible that the code could have a problem with the "Where" condition.

Try replacing the previous code with this code.

Dim strCompanyType As String
strCompanyType = "Retail Client"
DoCmd.OpenForm "Company_Main", acNormal, , "CompanyType = '" &
strCompanyType & "'"

Now, when you want to open the form to a different CompanyType, all you do
is change the string value that is being assigned to the "strCompanyType"
variable.
 
D

d9pierce

Dave,

I was not suggesting that you do not need the combo boxes on the main form.
I was only suggesting that you do not need one on your startup form.

The code that I provided should have worked. Are you sure that you do not
have some other issue going on. Do you have any other code that might be
causing a problem? Do you compile your code before attempting to run it?

It is possible that the code could have a problem with the "Where" condition.

Try replacing the previous code with this code.

Dim strCompanyType As String
strCompanyType = "Retail Client"
DoCmd.OpenForm "Company_Main", acNormal, , "CompanyType = '" &
strCompanyType & "'"

Now, when you want to open the form to a different CompanyType, all you do
is change the string value that is being assigned to the "strCompanyType"
variable.

--
HTH

Mr B







- Show quoted text -

Hi, Tried this and got a Syntex error, Expression Expected after the &
on third line?
dave
 
D

d9pierce

Dave,

I was not suggesting that you do not need the combo boxes on the main form.
I was only suggesting that you do not need one on your startup form.

The code that I provided should have worked. Are you sure that you do not
have some other issue going on. Do you have any other code that might be
causing a problem? Do you compile your code before attempting to run it?

It is possible that the code could have a problem with the "Where" condition.

Try replacing the previous code with this code.

Dim strCompanyType As String
strCompanyType = "Retail Client"
DoCmd.OpenForm "Company_Main", acNormal, , "CompanyType = '" &
strCompanyType & "'"

Now, when you want to open the form to a different CompanyType, all you do
is change the string value that is being assigned to the "strCompanyType"
variable.

--
HTH

Mr B







- Show quoted text -

Hi Mr B,
Idont really have anything going on on this db yet that could
interfear as I just started it. I did a similiar one and am currently
using it but rewriting this to sort of tweek it so to speak and give
it the actual functions my other one doesnt have now that I have been
using it for awhile. i dont have a combo box on the form "StartUp",
just cmd buttons. The only place I have companytype is on the
"Company_Main". I dont really have much of any code on the form that
could interfear with this cmd button. I just dont understand it. I
only have a cmd button to open contacts from "company_Main", A before
Update for the modify date, and a not in list for state combo box.
that is it so far1
This should work and work well but it doesnt?

thanks,
Dave
 
G

Guest

Sounds like word wrap in the newsgroup may have taken it toll again.

the strCompanyType & "" goes on the line above it. This is why you would get
the message you got.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top