Forms - linking autonumber

G

Guest

I have 2 forms. First form is used to supply a job number via autonumber.
The 2nd form is used to input additional job number information. How do I
open the second form showing the newly created job number at the top. I cant
use tab control pages because I already have a small one within form 1. I
have tried using page breaks to "simulate" the 2 forms but the pg breaks
didnt work well in form view. Is it possible to link the job number field on
form 2 to the job number created in form 1????

Thanks for any ideas/help!!!
 
A

Allen Browne

Provided the changes are already saved for the first form, yes you can do
that.

Dim strWhere As String
If Me.Dirty Then
Me.Dirty = False
End if
If Me.NewRecord Then
Beep
Else
strWhere = "[JobID] = " & Me.JobID
DoCmd.OpenForm "Form2", WhereCondition:=strWhere
End If

Note: If the JobID field in the table is Text (not Number), you need extra
quotes:
strWhere = "[JobID] = """ & Me.JobID & """"
 
G

Guest

Thanks for your help, but I have to ask where I enter that code at. Does it
get entered exactly as written? I am fairly new to code.

Allen Browne said:
Provided the changes are already saved for the first form, yes you can do
that.

Dim strWhere As String
If Me.Dirty Then
Me.Dirty = False
End if
If Me.NewRecord Then
Beep
Else
strWhere = "[JobID] = " & Me.JobID
DoCmd.OpenForm "Form2", WhereCondition:=strWhere
End If

Note: If the JobID field in the table is Text (not Number), you need extra
quotes:
strWhere = "[JobID] = """ & Me.JobID & """"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

smboyd said:
I have 2 forms. First form is used to supply a job number via autonumber.
The 2nd form is used to input additional job number information. How do I
open the second form showing the newly created job number at the top. I
cant
use tab control pages because I already have a small one within form 1. I
have tried using page breaks to "simulate" the 2 forms but the pg breaks
didnt work well in form view. Is it possible to link the job number field
on
form 2 to the job number created in form 1????

Thanks for any ideas/help!!!
 
A

Allen Browne

Paste the code into which ever event procedure should open the other form.

For example, you could set the On Click property of a command button to:
[Event Procedure]
and click the Build button (...) beside that, and paste the code between the
lines "Private Sub ..." and "End Sub".

Or you may prefer to put it in the DblClick event procedure of the JobID
field so that double-clicking the number opens the other form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Allen Browne said:
Provided the changes are already saved for the first form, yes you can do
that.

Dim strWhere As String
If Me.Dirty Then
Me.Dirty = False
End if
If Me.NewRecord Then
Beep
Else
strWhere = "[JobID] = " & Me.JobID
DoCmd.OpenForm "Form2", WhereCondition:=strWhere
End If

Note: If the JobID field in the table is Text (not Number), you need extra
quotes:
strWhere = "[JobID] = """ & Me.JobID & """"


smboyd said:
I have 2 forms. First form is used to supply a job number via autonumber.
The 2nd form is used to input additional job number information. How do
I
open the second form showing the newly created job number at the top. I
cant
use tab control pages because I already have a small one within form 1.
I
have tried using page breaks to "simulate" the 2 forms but the pg breaks
didnt work well in form view. Is it possible to link the job number
field on
form 2 to the job number created in form 1????

Thanks for any ideas/help!!!
 
G

Guest

Thanks!!!

Allen Browne said:
Paste the code into which ever event procedure should open the other form.

For example, you could set the On Click property of a command button to:
[Event Procedure]
and click the Build button (...) beside that, and paste the code between the
lines "Private Sub ..." and "End Sub".

Or you may prefer to put it in the DblClick event procedure of the JobID
field so that double-clicking the number opens the other form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Allen Browne said:
Provided the changes are already saved for the first form, yes you can do
that.

Dim strWhere As String
If Me.Dirty Then
Me.Dirty = False
End if
If Me.NewRecord Then
Beep
Else
strWhere = "[JobID] = " & Me.JobID
DoCmd.OpenForm "Form2", WhereCondition:=strWhere
End If

Note: If the JobID field in the table is Text (not Number), you need extra
quotes:
strWhere = "[JobID] = """ & Me.JobID & """"


smboyd said:
I have 2 forms. First form is used to supply a job number via autonumber.
The 2nd form is used to input additional job number information. How do
I
open the second form showing the newly created job number at the top. I
cant
use tab control pages because I already have a small one within form 1.
I
have tried using page breaks to "simulate" the 2 forms but the pg breaks
didnt work well in form view. Is it possible to link the job number
field on
form 2 to the job number created in form 1????

Thanks for any ideas/help!!!
 

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