Open form and go to specific record

A

Anne

I have a double click event on a Jobsform, when the contractor combobox is
double clicked, it opens the contractor form.
How can I go directly to the contractorId which I double clicked on the
other form?

Here is my double click event:
Private Sub ContractorSelect_DblClick(Cancel As Integer)
On Error GoTo Err_OpenContractor2_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FrmContractor"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenContractor2_Click:
Exit Sub

Err_OpenContractor2_Click:
MsgBox Err.Description
Resume Exit_OpenContractor2_Click

End Sub

Thanks,
Anne
 
G

Graham Mandeno

Hi Anne

You have a string variable called stLinkCriiteria, but you are not using it.
You need to do something like this before calling OpenForm:

stLinkCriteria = "[ContractorID]=" & Me.ContractorSelect

If ContractorID is a text field, then you must surround the value in quotes:

stLinkCriteria = "[ContractorID]=" & """" & Me.ContractorSelect & """"

If the name of the primary key field in the contractors table is not
ContractorID, then substitute it.
 
A

Anne

Which event would I do this on. I guess this needs to still be done on the
jobform, but what event would I use?
Anne


Graham Mandeno said:
Hi Anne

You have a string variable called stLinkCriiteria, but you are not using it.
You need to do something like this before calling OpenForm:

stLinkCriteria = "[ContractorID]=" & Me.ContractorSelect

If ContractorID is a text field, then you must surround the value in quotes:

stLinkCriteria = "[ContractorID]=" & """" & Me.ContractorSelect & """"

If the name of the primary key field in the contractors table is not
ContractorID, then substitute it.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Anne said:
I have a double click event on a Jobsform, when the contractor combobox is
double clicked, it opens the contractor form.
How can I go directly to the contractorId which I double clicked on the
other form?

Here is my double click event:
Private Sub ContractorSelect_DblClick(Cancel As Integer)
On Error GoTo Err_OpenContractor2_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FrmContractor"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenContractor2_Click:
Exit Sub

Err_OpenContractor2_Click:
MsgBox Err.Description
Resume Exit_OpenContractor2_Click

End Sub

Thanks,
Anne
 
G

Graham Mandeno

Hi Anne

Just insert the extra line of code before or after the line:
stDocName = "FrmContractor"

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Anne said:
Which event would I do this on. I guess this needs to still be done on the
jobform, but what event would I use?
Anne


Graham Mandeno said:
Hi Anne

You have a string variable called stLinkCriiteria, but you are not using it.
You need to do something like this before calling OpenForm:

stLinkCriteria = "[ContractorID]=" & Me.ContractorSelect

If ContractorID is a text field, then you must surround the value in quotes:

stLinkCriteria = "[ContractorID]=" & """" & Me.ContractorSelect & """"

If the name of the primary key field in the contractors table is not
ContractorID, then substitute it.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Anne said:
I have a double click event on a Jobsform, when the contractor
combobox
 
A

Anne

I figured I would have to do that, but I do not know what that code would
be.
Anne

Graham Mandeno said:
Hi Anne

Just insert the extra line of code before or after the line:
stDocName = "FrmContractor"

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Anne said:
Which event would I do this on. I guess this needs to still be done on the
jobform, but what event would I use?
Anne


Graham Mandeno said:
Hi Anne

You have a string variable called stLinkCriiteria, but you are not
using
it.
You need to do something like this before calling OpenForm:

stLinkCriteria = "[ContractorID]=" & Me.ContractorSelect

If ContractorID is a text field, then you must surround the value in quotes:

stLinkCriteria = "[ContractorID]=" & """" & Me.ContractorSelect & """"

If the name of the primary key field in the contractors table is not
ContractorID, then substitute it.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I have a double click event on a Jobsform, when the contractor
combobox
is
double clicked, it opens the contractor form.
How can I go directly to the contractorId which I double clicked on the
other form?

Here is my double click event:
Private Sub ContractorSelect_DblClick(Cancel As Integer)
On Error GoTo Err_OpenContractor2_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FrmContractor"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenContractor2_Click:
Exit Sub

Err_OpenContractor2_Click:
MsgBox Err.Description
Resume Exit_OpenContractor2_Click

End Sub

Thanks,
Anne
 
G

Graham Mandeno

But it was in my original reply:
You need to do something like this before calling OpenForm:

stLinkCriteria = "[ContractorID]=" & Me.ContractorSelect

If ContractorID is a text field, then you must surround the value in
quotes:

stLinkCriteria = "[ContractorID]=" & """" & Me.ContractorSelect & """"

If the name of the primary key field in the contractors table is not
ContractorID, then substitute it.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Anne said:
I figured I would have to do that, but I do not know what that code would
be.
Anne

Graham Mandeno said:
Hi Anne

Just insert the extra line of code before or after the line:
stDocName = "FrmContractor"

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Anne said:
Which event would I do this on. I guess this needs to still be done on the
jobform, but what event would I use?
Anne


Hi Anne

You have a string variable called stLinkCriiteria, but you are not using
it.
You need to do something like this before calling OpenForm:

stLinkCriteria = "[ContractorID]=" & Me.ContractorSelect

If ContractorID is a text field, then you must surround the value in
quotes:

stLinkCriteria = "[ContractorID]=" & """" & Me.ContractorSelect & """"

If the name of the primary key field in the contractors table is not
ContractorID, then substitute it.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I have a double click event on a Jobsform, when the contractor combobox
is
double clicked, it opens the contractor form.
How can I go directly to the contractorId which I double clicked
on
the
other form?

Here is my double click event:
Private Sub ContractorSelect_DblClick(Cancel As Integer)
On Error GoTo Err_OpenContractor2_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FrmContractor"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenContractor2_Click:
Exit Sub

Err_OpenContractor2_Click:
MsgBox Err.Description
Resume Exit_OpenContractor2_Click

End Sub

Thanks,
Anne
 
A

Anne

Yes, it works, I added it right after the stLinkCriteria =
"[ContractorID]"......etc
Thanks so much,
Anne

Graham Mandeno said:
But it was in my original reply:
You need to do something like this before calling OpenForm:

stLinkCriteria = "[ContractorID]=" & Me.ContractorSelect

If ContractorID is a text field, then you must surround the value in
quotes:

stLinkCriteria = "[ContractorID]=" & """" & Me.ContractorSelect & """"

If the name of the primary key field in the contractors table is not
ContractorID, then substitute it.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Anne said:
I figured I would have to do that, but I do not know what that code would
be.
Anne

Graham Mandeno said:
Hi Anne

Just insert the extra line of code before or after the line:
stDocName = "FrmContractor"

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Which event would I do this on. I guess this needs to still be done
on
the
jobform, but what event would I use?
Anne


Hi Anne

You have a string variable called stLinkCriiteria, but you are not using
it.
You need to do something like this before calling OpenForm:

stLinkCriteria = "[ContractorID]=" & Me.ContractorSelect

If ContractorID is a text field, then you must surround the value in
quotes:

stLinkCriteria = "[ContractorID]=" & """" & Me.ContractorSelect & """"

If the name of the primary key field in the contractors table is not
ContractorID, then substitute it.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I have a double click event on a Jobsform, when the contractor
combobox
is
double clicked, it opens the contractor form.
How can I go directly to the contractorId which I double clicked on
the
other form?

Here is my double click event:
Private Sub ContractorSelect_DblClick(Cancel As Integer)
On Error GoTo Err_OpenContractor2_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FrmContractor"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenContractor2_Click:
Exit Sub

Err_OpenContractor2_Click:
MsgBox Err.Description
Resume Exit_OpenContractor2_Click

End Sub

Thanks,
Anne
 

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