HELP!!! URGENT!! ON DEADLINE!!!

  • Thread starter Thread starter James
  • Start date Start date
J

James

Would you like to have a look at the database?

Would this help matters any?

Cheers

James
-----Original Message-----
OK try code like:

Private Sub Form_BeforeInsert(Cancel As Integer)
Dim f as Access.Form
Set f = Forms![YourFirstFormName] 'This will raise an error if the form
is not loaded
Me.[txtReference_No] = f.[txtReference_No]
End Sub

--

Cheers
Mark

Free Access/Office Add-Ins at:
http://mphillipson.users.btopenworld.com/



James said:
Thanks for that but I think that this is a little more
complex than what I require....

What I am after is that one the first form I have a
refrence number which is inputted by the user and then on
each other form it looks up that refrence number from the
first form.

All I require it to do is that when the refrence number is
pulled from teh first form it gets added into the table by
default.

Many Thanks

James
-----Original Message-----
Hi James,

If you need the reference number to increment by 1 each time a new record is
added, then enter code like the following in say the Before Insert Event:

Private Sub Form_BeforeInsert(Cancel As Integer)
'Get Next Reference Number
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQLText As String
Set db = CurrentDb
strSQLText = "SELECT Max(tblSomeTable.Reference_No) AS Reference_No" &
vbCrLf
strSQLText = strSQLText & " FROM tblSomeTable;"
Set rs = db.OpenRecordset(strSQLText)
If Not rs.EOF Then
rs.MoveFirst
Me.txtReference_No = Format(Nz(rs!
[Reference_No], "0") + 1, "00000")
End If
rs.Close
End Sub

You would need to change tblSomeTable to the name of
your
table.
Cheers
Mark

Free Access/Office Add-Ins at:
http://mphillipson.users.btopenworld.com/





Hello I have a text box that is a refrence number which
will follow on from from to form how do I get this to
automatically be inputted within the text box that follows?

Many Thanks

James
 
Need more info! What are you trying to do and what is this
code doing that is causing you problems?

Kevin
-----Original Message-----
Would you like to have a look at the database?

Would this help matters any?

Cheers

James
-----Original Message-----
OK try code like:

Private Sub Form_BeforeInsert(Cancel As Integer)
Dim f as Access.Form
Set f = Forms![YourFirstFormName] 'This will raise
an
error if the form
is not loaded
Me.[txtReference_No] = f.[txtReference_No]
End Sub

--

Cheers
Mark

Free Access/Office Add-Ins at:
http://mphillipson.users.btopenworld.com/



James said:
Thanks for that but I think that this is a little more
complex than what I require....

What I am after is that one the first form I have a
refrence number which is inputted by the user and then on
each other form it looks up that refrence number from the
first form.

All I require it to do is that when the refrence
number
table
by
default.

Many Thanks

James
-----Original Message-----
Hi James,

If you need the reference number to increment by 1 each
time a new record is
added, then enter code like the following in say the
Before Insert Event:

Private Sub Form_BeforeInsert(Cancel As Integer)
'Get Next Reference Number
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQLText As String
Set db = CurrentDb
strSQLText = "SELECT Max (tblSomeTable.Reference_No)
AS Reference_No" &
vbCrLf
strSQLText = strSQLText & " FROM tblSomeTable;"
Set rs = db.OpenRecordset(strSQLText)
If Not rs.EOF Then
rs.MoveFirst
Me.txtReference_No = Format(Nz(rs!
[Reference_No], "0") + 1, "00000")
End If
rs.Close
End Sub

You would need to change tblSomeTable to the name of your
table.

Cheers
Mark

Free Access/Office Add-Ins at:
http://mphillipson.users.btopenworld.com/





Hello I have a text box that is a refrence number which
will follow on from from to form how do I get this to
automatically be inputted within the text box that
follows?

Many Thanks

James

.
 
It all should be in the text below my original post.

Thanks

James
-----Original Message-----
Need more info! What are you trying to do and what is this
code doing that is causing you problems?

Kevin
-----Original Message-----
Would you like to have a look at the database?

Would this help matters any?

Cheers

James
-----Original Message-----
OK try code like:

Private Sub Form_BeforeInsert(Cancel As Integer)
Dim f as Access.Form
Set f = Forms![YourFirstFormName] 'This will raise
an
error if the form
is not loaded
Me.[txtReference_No] = f.[txtReference_No]
End Sub

--

Cheers
Mark

Free Access/Office Add-Ins at:
http://mphillipson.users.btopenworld.com/



Thanks for that but I think that this is a little more
complex than what I require....

What I am after is that one the first form I have a
refrence number which is inputted by the user and
then
on
each other form it looks up that refrence number from the
first form.

All I require it to do is that when the refrence
number
is
pulled from teh first form it gets added into the
table
by
default.

Many Thanks

James
-----Original Message-----
Hi James,

If you need the reference number to increment by 1 each
time a new record is
added, then enter code like the following in say the
Before Insert Event:

Private Sub Form_BeforeInsert(Cancel As Integer)
'Get Next Reference Number
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQLText As String
Set db = CurrentDb
strSQLText = "SELECT Max (tblSomeTable.Reference_No)
AS Reference_No" &
vbCrLf
strSQLText = strSQLText & " FROM tblSomeTable;"
Set rs = db.OpenRecordset(strSQLText)
If Not rs.EOF Then
rs.MoveFirst
Me.txtReference_No = Format(Nz(rs!
[Reference_No], "0") + 1, "00000")
End If
rs.Close
End Sub

You would need to change tblSomeTable to the name of your
table.

Cheers
Mark

Free Access/Office Add-Ins at:
http://mphillipson.users.btopenworld.com/





Hello I have a text box that is a refrence number which
will follow on from from to form how do I get this to
automatically be inputted within the text box that
follows?

Many Thanks

James

.
.
 
It all should be in the text below my original post.

That's just plain rude, James. You are NOT the only person posting
questions here. You presumably have easy access to the text of your
original post; the volunteers here must use Google or archives to
search for it.

If it's all that urgent, one would think that you could expedite the
process by providing the information needed to answer your question.
 
Back
Top