Forms - linking autonumber

  • Thread starter Thread starter Guest
  • Start date Start date
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!!!
 
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 & """"
 
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!!!
 
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!!!
 
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!!!
 
Back
Top