ComboBox Condition from first Form to a second one.

G

Guest

Hi all..

I need help on this, I don’t know what I’m doing incorrect.

I have a Form (startup) opened and I have selected my UserID, from a
combobox , but I want to open another form but I want that my UserID selected
in startup form appear selected in my second form (Orders),

“â€first form informationâ€â€

Name of first form: Password
Name of Combo: Combo1
Statements of combo conditions : SELECT [Users].[UserID], [LastName] & " , "
& [FirstName] AS
Name, [Users].[Password], [Users].[OrderPerson], [Users].[ApproverPerson],
[Users].[ReceiverPerson], [Users].[AdminPerson], [Users].[Active] FROM Users
WHERE ((([Users].[Active])=Yes)) Or ((([Users].[Active])=Yes)) ORDER BY
[Users].[Password];

Name of table that it’s belong: Users

“â€Second form informationâ€
Name of second form: Orders
Name of Combo: UserID
Statements of combo conditions : SELECT [Users].[UserID], [LastName] & " ,
" & [FirstName] AS
Name FROM Users;

Name of table that it’s belong: Users


“â€â€I have written this code in the button that open the second form""

What I doing incorrect?? Please help me!!

-_____________________________________
Private Sub OpenOrders_Click()
On Error GoTo Err_OpenOrders_Click
DoCmd.Close ‘’ this will close first form


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Orders" ‘’ Name of second form


stLinkCriteria = [UserID] = " & Me![Combo1]"
If Not Me![Combo1] Then

DoCmd.OpenForm stDocName, , , stLinkCriteria

Else
MsgBox "You need select your User", vbCritical, "Error"



End If

Exit_OpenOrders_Click:
Exit Sub

Err_OpenOrders_Click:
MsgBox Err.Description
Resume Exit_OpenOrders_Click

End Sub
_____________________________________________

Thanks to see my question
(e-mail address removed)

ldiaz
 
L

Larry Linson

Me!Combo1 will be a Null, or a Null String "", or Text. It will never be the
True/False value for which you test in

If Not (Me![Combo1]) Then

also,

stLinkCriteria = [UserID] = " & Me![Combo1]"

will always set stLinkCriteria to the value False, because whatever
associated with your form with the name UserId is almost certainly never the
string " & Me![Combo1]"

If UserID is a text field, that should read

stLinkCriteria = "[UserID] = """ & Me![Combo1] & """"

Please note that I don't do "remote debugging" in the newsgroups -- these
were just two obvious things that "stood out" to me.

All that said, trying to implement your own "Security Lite" is not really
worth your while. Access has better security available than can be built
into the database itself, and even that is breakable. You'll have to learn
Access security and implement it, but you won't have to debug the whole
security method for coding errors.

Larry Linson
Microsoft Access MVP
 
J

John Vinson

I have a Form (startup) opened and I have selected my UserID, from a
combobox , but I want to open another form but I want that my UserID selected
in startup form appear selected in my second form (Orders),

Change the RowSource property of the combo in the second form to
reference the first form. As you have it:

“”Second form information”
Name of second form: Orders
Name of Combo: UserID
Statements of combo conditions : SELECT [Users].[UserID], [LastName]
& " , " & [FirstName] AS
Name FROM Users;

it's simply selecting all records from Users; it has no idea that
you've done anything to limit the users you want to see.

Change the RowSource property to


SELECT [Users].[UserID], [LastName] & " , " & [FirstName] AS
Name FROM Users WHERE Users.UserID =
[Forms]![Switchboard]![cboUserID];

using the actual name of your switchboard form and the user combo box.
This will of course be a pretty pointless combo box since it will have
only one row!


John W. Vinson[MVP]
 

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