Linkcriteria for drag a conbobox information

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 : 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 : 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
 
S

Steve Schapel

ldiaz,

There appear to be several syntax errors in your code, as well as
unnecessary complexity. Try it like this (I am assuming that UserID is
a numerical field, right? ...
_________
Private Sub OpenOrders_Click()
On Error GoTo Err_OpenOrders_Click

If IsNull(Me.Combo1) Then
DoCmd.OpenForm "Orders, , , "[UserID]=" & Me.Combo1
Else
MsgBox "You need select your User", vbCritical, "Error"
End If
DoCmd.Close acForm, Me.Name

Exit_OpenOrders_Click:
Exit Sub

Err_OpenOrders_Click:
MsgBox Err.Description
Resume Exit_OpenOrders_Click

End Sub
_________
 
G

Guest

Hi Steve,,

I did your expression but it does not work yet...

appear a message like this: " The expression that you entered refers to an
object that is closed or does not exist"


and UserID is autonumber of table where I pull the Name ,last Name,Password
,ETC,, ,,but also is the name of ComboBox in second form..

please help me to clarify this,,,I did this before but I don't remember how...


Thanks.
ldiaz




Steve Schapel said:
ldiaz,

There appear to be several syntax errors in your code, as well as
unnecessary complexity. Try it like this (I am assuming that UserID is
a numerical field, right? ...
_________
Private Sub OpenOrders_Click()
On Error GoTo Err_OpenOrders_Click

If IsNull(Me.Combo1) Then
DoCmd.OpenForm "Orders, , , "[UserID]=" & Me.Combo1
Else
MsgBox "You need select your User", vbCritical, "Error"
End If
DoCmd.Close acForm, Me.Name

Exit_OpenOrders_Click:
Exit Sub

Err_OpenOrders_Click:
MsgBox Err.Description
Resume Exit_OpenOrders_Click

End Sub
_________

--
Steve Schapel, Microsoft Access MVP

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 : 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 : 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
 
S

Steve Schapel

Idiaz,

I see there was a typo in the code I gave... I accidentally omitted the
" at the end of the word "Orders". Maybe that's the problem.
Otherwise, just checking that the combobox is named Combo1?

DoCmd.OpenForm "Orders", , , "[UserID]=" & Me.Combo1
 
G

Guest

Hi Steve,,I sent to you yesterday my Database, because what I want does not
work,,I have tried many tmes and it does not work,,,if you could help me it
will be great..

Thanks...

ldiaz




Steve Schapel said:
Idiaz,

I see there was a typo in the code I gave... I accidentally omitted the
" at the end of the word "Orders". Maybe that's the problem.
Otherwise, just checking that the combobox is named Combo1?

DoCmd.OpenForm "Orders", , , "[UserID]=" & Me.Combo1

--
Steve Schapel, Microsoft Access MVP

Hi Steve,,

I did your expression but it does not work yet...

appear a message like this: " The expression that you entered refers to an
object that is closed or does not exist"


and UserID is autonumber of table where I pull the Name ,last Name,Password
,ETC,, ,,but also is the name of ComboBox in second form..

please help me to clarify this,,,I did this before but I don't remember how...


Thanks.
ldiaz
 
S

Steve Schapel

Idiaz,

Ok, I would be willing to have a look. You would need to remove the .ns
from the end of my return email address.
 
G

Guest

Hi Steve,,

I already sent it to you again,,please advise me if you got it..

anyway thank you so much to take a moment to see my question..

From Mx ldiaz
 
S

Steve Schapel

Ldiaz,

I have received your database. I can't really see the problem. It
seems to work correctly with the code I suggested to you before. It is
not easy to test, because there is only one Order entered in the Orders
table, and that is by UserID of Díaz , Lorenzo who does not have access
to orders from the password form. But if you change to Aguila ,
Cristina as the User for that Order, then the Orders form does open
showing her order. I mean, if you want the Orders form to open to show
the orders of the logged-in User, then there have to be some orders for
the logged-in user in the database, otherwise you can't see anything of
course.

I notice you have used a Lookup Field for the UserID in your Orders
table. This is never a good idea. See
http://www.mvps.org/access/lookupfields.htm . Maybe this is causing you
some confusion.
 
G

Guest

Hi Steve,,Thank you os much for your attention..

I have been trying many times and it does not work yet,,
I have entered many orders now with Francisco Valencia and it does not work ,
also I changed the Source of form and subform from Table to query, to put a
criteria where Orders not approved are appear in the form..

anyway thank youn so much for your help..

This is my job e-mail.

(e-mail address removed)

and thank you so much again..

if you know ohter option please let me know..

ldiaz
 
S

Steve Schapel

Ldiaz,

It would not be appropriate for me to email you. We should keep our
correspondence in the newsgroup.

So you have entered some orders where the UserID is Francisco Valencia.
Ok. Then, if you go to the Password form, enter Francisco Valencia,
enter the password, click the 'Click Here' button, which should enable
the 'Orders' button, doesn't it open the Orders form with Francisco
Valencia's first recorded order displayed? That's what happens on mine!
Of course, I would use the code I suggested on the 'Orders' command
button, i.e....
Private Sub OpenOrders_Click()
If IsNull(Me.Combo1) Then
DoCmd.OpenForm "Orders, , , "[UserID]=" & Me.Combo1
Else
MsgBox "You need select your User", vbCritical, "Error"
End If
DoCmd.Close acForm, Me.Name
End Sub

.... but it seems to work ok even with the code as in the database you
sent me. So, I don't know what is going on here. It is very strange if
we are both using the exact same file, and we are seeing different
behaviour. What happens for you, if you follow the above steps, and how
is this different from what you expect?
 

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