Browse, Open file, assign number on file, and print

Tech-Archive recommends: Fix windows errors by optimizing your registry



I have one letter on the shared drive that need to be printed several times
with different sequence numbers each time the letter is printed. I need to
be able to

1. browse and OPEN the letter. (PROBLEM:the browse window opens, but I can?t
bring up the actual letter)
2. print a number (that I have generated in Access) in the bottom left corner
of the letter. Don't know if a bookmark is better or just a print location
will do.
3. and then print the letter.

I need to repeat this operation several times.

- Once the first letter is printed, I don?t need to browse for the letter
again.
- I want to keep the letter open and just print the next number sequence
replaced on the letter
- and then print the letter.

The only thing that is changing is the printed sequence number generated from
Access. This is being used to keep track of the letters sent.

Please help me with this problem. Below is my code.

Private Sub PrintSrv_Click()
'save demographics to table
DoCmd.Save
'browse to find letter

Dim strFilter As String
Dim lngFlags As Long
Dim strFileName As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

Debug.Print Hex(lngFlags)

strInputFileName = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)


'Open a database -
'don't know if I should set the database, since the database may reside
almost anywhere
Set myDataBase = OpenDatabase("C:\Documents\Letters2005.mdb")

'Access the first record from a particular table

Set myActiveRecord = myDataBase.OpenRecordset("Table_1", dbOpenForwardOnly)

'Loop through all the records in the table until the end-of-file marker is
reached

Do While Not myActiveRecord.EOF

'If field #1 contains a non-zero value,
'insert the value of field #2 into the document
'after the current cursor or selection location
'This requires the user to place the cursor somewhere. Can there be a
routine to place it at the bottom of the
'letter without cursor placement?
If myActiveRecord.Fields("Field_1") <> 0 Then
Selection.InsertAfter myActiveRecord.Fields("Field_2")
End If

'access the next record
myActiveRecord.MoveNext

SrvNo = Field_1
RefNo = Field_2
Loop
'saves ref # and count to table
DoCmd.Save

'prints letter with ref # on it
Me!RefNo = NZ(DMax("[Ltrid]", "[qryHome]", "[DateSeq] >= #" & DateSerial(Year
(Date()), Month(Date()), 1)) + 1

'leave word doc open to print next ref# on already open document

'If no more printing
'Then close the database
'myActiveRecord.Close
'myDataBase.Close




End Sub

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200511/1
.



Relevant Pages

  • Re: problem using identity column as primary key
    ... >> I am thinking of creating an identity column to use it as primary key ... More and more programmers who have absolutely no database training are ... the gap in the sequence is not filled in and the sequence ... vin CHARNOT NULL REFERENCES Motorpool); ...
    (microsoft.public.sqlserver.programming)
  • Re: Concatenate and Null Values -- Features
    ... I have to say it's hard for me to see how a sequence number such as I have ... I should probably mention that this database is unlikely to generate more ... I wonder if storing 07-01 (probably without the dash, ... I think I know what you're saying about learning by teaching. ...
    (microsoft.public.access.reports)
  • Re: Table Design Question
    ... > requires more than two probes, no matter how large the database. ... > acceptable (in the relational model) to have an Identity attribute to ... the gap in the sequence is not filled in and the sequence ... > vin CHARNOT NULL REFERENCES Motorpool); ...
    (microsoft.public.sqlserver.programming)
  • Re: Table Design Question
    ... no matter how large the database. ... the gap in the sequence is not filled in and the sequence ... ssn CHARNOT NULL REFERENCES Personnel, ... vin CHARNOT NULL REFERENCES Motorpool); ...
    (microsoft.public.sqlserver.programming)
  • Re: why use 4nf?
    ... no matter how large the database. ... acceptable (in the relational model) to have an Identity attribute to ... the gap in the sequence is not filled in and the sequence ... vin CHARNOT NULL REFERENCES Motorpool); ...
    (microsoft.public.sqlserver.programming)