Hi,

Having read the announcement about kids doing homework I am a little worried now that I am gonna get a backlash.

I work for a company that has pushed Access onto us as our Database Function unfortunateley they have not trained our IT to help when something goes wrong or indeed when something new needs to be done.

I have a system that was set up by a person who has now retired, we updated it in August and now need to put a new function in.

At the moment we have a setting where you select an option on a DropDown List and click a button, this automatically saves an .rtf into a folder using one of the fields in the record as its name.

This works great for that particular Form, but unfortunately I have had to create a secondary form and need to be able to perform the same function based on a different report and form.

I don't know Visual Basic much, I can logically assume what some of the coding means but when it comes to writing it I am pretty stuck.

Any help that can be offered would be greatly appreciated, they are now trying to put us onto Oracle as IT support that, but unfortunately Oracle doesn't perform how we need it to, so I need to get this right.

Thanks

Nikki

How do you expect us to help you without having any detail idea of what is happening at your side and what exactly is your requirment.

Ok, apologies for vagueness, my initial question was more of a general, 'Am I ok to request help on here?' type of thing. So I will get down to details....

Within a form called Q22-CR I have to put a button, when that button is pressed I want it to run a report [q22landcharges] and save it as an .rtf in a designated folder (same folder for all) but each time using the [Official Search Number] as its name so there is no user input at the time of saving. (I have made it work via a macro but each time you have to follow the path to the file and select the type of file you want it to be saved as)

This works already for another form within the database but this has to be a separate .rtf the code already in place is:

Private Sub cmdOptions_Click()
On Error GoTo myerr

Dim rpt As String
Dim strDest As String

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

create_a:

Select Case Me.cboOptions

Case 1
If Me.[Optional Text Q2] = -1 Then
DoCmd.OpenReport "rpt:landcharges"
Else
DoCmd.OpenReport "rpt:landchargesw"
End If

Case 3
If Me.[Optional Text Q2] = -1 Then
rpt = "rpt:LandCharges"
strDest = "I:\landchar\searches\" & [Forms]![frm:detailsInput]![Official Search Number] & ".rtf"
'strDest = "P:\landcharges\" & [Forms]![frm:detailsInput]![Official Search Number] & "land charges report.rtf"
'strDest = "P:\landsrch\searches\" & [Forms]![frm:detailsInput]![Official Search Number] & ".rtf"
'strDest = "C:\My Documents\" & [Forms]![frm:detailsInput]![Official Search Number] & ".rtf"
Else
rpt = "rpt:LandChargesW"
strDest = "I:\landchar\searches\" & [Forms]![frm:detailsInput]![Official Search Number] & ".rtf"
'strDest = "P:\landcharges\" & [Forms]![frm:detailsInput]![Official Search Number] & " no land charges report.rtf"
'strDest = "P:\landsrch\searches\" & [Forms]![frm:detailsInput]![Official Search Number] & ".rtf"
'strDest = "C:\My Documents\" & [Forms]![frm:detailsInput]![Official Search Number] & ".rtf"
End If
DoCmd.OutputTo acOutputReport, rpt, acFormatRTF, strDest

Case Else
'DoCmd.OpenForm "frm:tabsearch", acNormal
If Me.[Optional Text Q2] = -1 Then
DoCmd.OpenReport "rpt:LandCharges", acViewPreview
Else
DoCmd.OpenReport "rpt:LandChargesW", acViewPreview
End If
End Select
exit_cre:
Exit Sub

myerr:

Dim fs As Object

If Err.Number = 58 Then
fs.deletefile (strDest)
GoTo create_a
Else
MsgBox (Err.Number & " " & Err.Source & " - " & Err.Description)
GoTo exit_cre
End If
End Sub

Private Sub Form_Activate()

DoCmd.Maximize

End Sub

Private Sub Form_Open(Cancel As Integer)

DoCmd.Maximize

End Sub

I feel this is a much more convoluted way of doing it and would be hoping for something a lot simpler for the Q22-CR as it has no and or if parameters it is the same conditioning each time.

Thanks

Nikki

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.