datasheet click troubles.

I

ifoundgoldbug

this is the proper way everyone says this should be done.

Private Sub Work_Order___DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim test As Double

stDocName = "work order"

stLinkCriteria = Me![work order #]

' note that Me![work order #] and [work order]![work order #] are
the same field on different
' tables

DoCmd.OpenForm stDocName, , , "[work order]![work order #] = " &
stLinkCriteria

End Sub

the above code genereates the error "the OpenForm action was cancelled"
which I am told means that something is tryped in wrong. But even when
i get past this error it brings up a BLANK form instead of the record
that I was looking for.



Now where it gets screwy. here is code that does almost exactly what I
want (bring up the proper record) but I have NO idea how it does by all
means it SHOULDN"T



Private Sub Work_Order___DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim test As Double

stDocName = "work order"

stLinkCriteria = Me![work order #]
DoCmd.OpenForm stDocName, , , "[work order #] = stLinkCriteria"
End Sub

the above code will give me a dialog box where I enter in the value of
stlinkcriteria and it retrieves and displays that record. after the
dialog box is close stlinkcriteria goes back to it former value.
 
S

Stefan Hoffmann

hi,

this is the proper way everyone says this should be done.

Private Sub Work_Order___DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim test As Double

stDocName = "work order"

stLinkCriteria = Me![work order #]

' note that Me![work order #] and [work order]![work order #] are
the same field on different
' tables

DoCmd.OpenForm stDocName, , , "[work order]![work order #] = " &
stLinkCriteria

End Sub

the above code genereates the error "the OpenForm action was cancelled"
which I am told means that something is tryped in wrong. But even when
i get past this error it brings up a BLANK form instead of the record
that I was looking for.
I assume you order# is alphanumeric, so you have to put it in quotes:

stLinkCriteria = "'" & Replace(Me![work order #], "'", "''") & "'"


mfG
--> stefan <--
 
G

Guest

First, this statment:
' note that Me![work order #] and [work order]![work order #] are
the same field on different
' tables

Does not make sense. Me! relates to a form, not a field in a table (note,
regardless of what you may have read in any Microsoft publications, there are
no fields on forms. Forms have controls and controls can be bound to fields
in tables and queries.) Also, you are setting the filter to the value of the
current record, unless this is a different form.

I think the problem is probably just a syntax issue. If the field in your
table named [work order #] is numeric, then the syntax is correct and there
is another problem. If it is text, then it need to surrounded with quotes,
either double or single. Try this syntax:

stLinkCriteria = "[work order]![work order #] = '" & Me![work order #]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


this is the proper way everyone says this should be done.

Private Sub Work_Order___DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim test As Double

stDocName = "work order"

stLinkCriteria = Me![work order #]

' note that Me![work order #] and [work order]![work order #] are
the same field on different
' tables

DoCmd.OpenForm stDocName, , , "[work order]![work order #] = " &
stLinkCriteria

End Sub

the above code genereates the error "the OpenForm action was cancelled"
which I am told means that something is tryped in wrong. But even when
i get past this error it brings up a BLANK form instead of the record
that I was looking for.



Now where it gets screwy. here is code that does almost exactly what I
want (bring up the proper record) but I have NO idea how it does by all
means it SHOULDN"T



Private Sub Work_Order___DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim test As Double

stDocName = "work order"

stLinkCriteria = Me![work order #]
DoCmd.OpenForm stDocName, , , "[work order #] = stLinkCriteria"
End Sub

the above code will give me a dialog box where I enter in the value of
stlinkcriteria and it retrieves and displays that record. after the
dialog box is close stlinkcriteria goes back to it former value.
 
I

ifoundgoldbug

actually it was a case of "it's not what i say it's what I mean" i
meant to say that both work order number are 2 forms accessing the same
field/record on 1 table appologies for the confusion
Klatuu said:
First, this statment:
' note that Me![work order #] and [work order]![work order #] are
the same field on different
' tables

Does not make sense. Me! relates to a form, not a field in a table (note,
regardless of what you may have read in any Microsoft publications, there are
no fields on forms. Forms have controls and controls can be bound to fields
in tables and queries.) Also, you are setting the filter to the value of the
current record, unless this is a different form.

I think the problem is probably just a syntax issue. If the field in your
table named [work order #] is numeric, then the syntax is correct and there
is another problem. If it is text, then it need to surrounded with quotes,
either double or single. Try this syntax:

stLinkCriteria = "[work order]![work order #] = '" & Me![work order #]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


this is the proper way everyone says this should be done.

Private Sub Work_Order___DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim test As Double

stDocName = "work order"

stLinkCriteria = Me![work order #]

' note that Me![work order #] and [work order]![work order #] are
the same field on different
' tables

DoCmd.OpenForm stDocName, , , "[work order]![work order #] = " &
stLinkCriteria

End Sub

the above code genereates the error "the OpenForm action was cancelled"
which I am told means that something is tryped in wrong. But even when
i get past this error it brings up a BLANK form instead of the record
that I was looking for.



Now where it gets screwy. here is code that does almost exactly what I
want (bring up the proper record) but I have NO idea how it does by all
means it SHOULDN"T



Private Sub Work_Order___DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim test As Double

stDocName = "work order"

stLinkCriteria = Me![work order #]
DoCmd.OpenForm stDocName, , , "[work order #] = stLinkCriteria"
End Sub

the above code will give me a dialog box where I enter in the value of
stlinkcriteria and it retrieves and displays that record. after the
dialog box is close stlinkcriteria goes back to it former value.
 
I

ifoundgoldbug

that got it working thank you so mcuh for your time.


Gold Bug


actually it was a case of "it's not what i say it's what I mean" i
meant to say that both work order number are 2 forms accessing the same
field/record on 1 table appologies for the confusion
Klatuu said:
First, this statment:
' note that Me![work order #] and [work order]![work order #] are
the same field on different
' tables

Does not make sense. Me! relates to a form, not a field in a table (note,
regardless of what you may have read in any Microsoft publications, there are
no fields on forms. Forms have controls and controls can be bound to fields
in tables and queries.) Also, you are setting the filter to the value of the
current record, unless this is a different form.

I think the problem is probably just a syntax issue. If the field in your
table named [work order #] is numeric, then the syntax is correct and there
is another problem. If it is text, then it need to surrounded with quotes,
either double or single. Try this syntax:

stLinkCriteria = "[work order]![work order #] = '" & Me![work order #]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria


this is the proper way everyone says this should be done.

Private Sub Work_Order___DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim test As Double

stDocName = "work order"

stLinkCriteria = Me![work order #]

' note that Me![work order #] and [work order]![work order #] are
the same field on different
' tables

DoCmd.OpenForm stDocName, , , "[work order]![work order #] = " &
stLinkCriteria

End Sub

the above code genereates the error "the OpenForm action was cancelled"
which I am told means that something is tryped in wrong. But even when
i get past this error it brings up a BLANK form instead of the record
that I was looking for.



Now where it gets screwy. here is code that does almost exactly what I
want (bring up the proper record) but I have NO idea how it does by all
means it SHOULDN"T



Private Sub Work_Order___DblClick(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim test As Double

stDocName = "work order"

stLinkCriteria = Me![work order #]
DoCmd.OpenForm stDocName, , , "[work order #] = stLinkCriteria"
End Sub

the above code will give me a dialog box where I enter in the value of
stlinkcriteria and it retrieves and displays that record. after the
dialog box is close stlinkcriteria goes back to it former value.
 

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