Help Printing Current Record

R

Richard

I am working on a multi-user form / subform one to many relationship. Two
data tables, master table (tblWarehouse) primary key set to WareID /
autonumber child table (tblPurchData) primary key set to PurchaseOrderID /
autonumber with a foreign key WareID from the master table. I want to be able
to print direct from the form. I have used this code in the past found on
Allen Browne's web page.

Private Sub cmdPrint_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub

My question is can this be adapted to my situation? I have tried it with no
luck..any help or examples would be most appreciated..
 
R

Richard

Thanks you guys awesome!

Arvin Meyer said:
Sure just change ID to WareID
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Richard said:
I am working on a multi-user form / subform one to many relationship. Two
data tables, master table (tblWarehouse) primary key set to WareID /
autonumber child table (tblPurchData) primary key set to PurchaseOrderID
/
autonumber with a foreign key WareID from the master table. I want to be
able
to print direct from the form. I have used this code in the past found on
Allen Browne's web page.

Private Sub cmdPrint_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub

My question is can this be adapted to my situation? I have tried it with
no
luck..any help or examples would be most appreciated..
 
R

Richard

Arvin,

I would like to add a "new record" after the print code runs...so that the
form clears..Thanks again

Richard said:
Thanks you guys awesome!

Arvin Meyer said:
Sure just change ID to WareID
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Richard said:
I am working on a multi-user form / subform one to many relationship. Two
data tables, master table (tblWarehouse) primary key set to WareID /
autonumber child table (tblPurchData) primary key set to PurchaseOrderID
/
autonumber with a foreign key WareID from the master table. I want to be
able
to print direct from the form. I have used this code in the past found on
Allen Browne's web page.

Private Sub cmdPrint_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub

My question is can this be adapted to my situation? I have tried it with
no
luck..any help or examples would be most appreciated..
 
A

Arvin Meyer [MVP]

Piece of cake. Just before the End Sub, add a new line of code:

DoCmd.GoToRecord , , acNewRec

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

Richard said:
Arvin,

I would like to add a "new record" after the print code runs...so that the
form clears..Thanks again

Richard said:
Thanks you guys awesome!

Arvin Meyer said:
Sure just change ID to WareID
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

I am working on a multi-user form / subform one to many relationship.
Two
data tables, master table (tblWarehouse) primary key set to WareID /
autonumber child table (tblPurchData) primary key set to
PurchaseOrderID
/
autonumber with a foreign key WareID from the master table. I want to
be
able
to print direct from the form. I have used this code in the past
found on
Allen Browne's web page.

Private Sub cmdPrint_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub

My question is can this be adapted to my situation? I have tried it
with
no
luck..any help or examples would be most appreciated..
 

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