Solved

An MS Access form issue

Posted on 2004-10-06
7
231 Views
Last Modified: 2006-11-17
Hi all,

I have a form in Access which has 3 combo boxes representing the entities accountname, date and report type respectively. The value in these comboboxes is coming from 3 separate tables which are 2 column tables: one for say account name and one for the primary key.
Now according to the chosen combination in the form what happens is that on pressing a command button 'pdf display' a pdf file opens up which is named as 'accountname' + 'reporttype' + 'date'. For eg:
If the user choses Microsoft and Report1 and 10/04/2004 then the report which opens up is named microsoftreport110/04/2004.pdf.

Now  i was trying to get this functionality in VBA code (given below). What happens but is that instead of the value stored in cboaccountname, which is the accountname the user has chosen in the combo box, the text cboaccountname itself gets transferred. I tried giving it as &cboaccountname& but of no use. The same is the case with report type and date.
Any ideas !

Private Sub cmddri_Click()

Dim pdflink As String

If IsNull(Cboaccountnamei) Or Cboaccountnamei = "" Then
        MsgBox "Select Account Name"
        Cboaccountnamei.SetFocus
    ElseIf IsNull(cboreporttypei) Or cboreporttypei = "" Then
        MsgBox "Select Report Type"
        Cboaccountnamei.SetFocus
    ElseIf IsNull(cbodatesi) Or cbodatesi = "" Then
        MsgBox "Select Date"
        Cboaccountnamei.SetFocus
       
    Else

pdflink = "\\lvamfs01\shared\axysreportscreation\" + Cboaccountname.Value + cboreporttype.value + cbodate.value + ".pdf "

Debug.Print pdflink

FollowHyperlink pdflink, , True

End If

End Sub

Cheers
Goels
0
Comment
Question by:Goels
7 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 12240191
can you set a Breakpoint on the  line

If IsNull(Cboaccountnamei) Or Cboaccountnamei = "" Then


and then single step (debug mode - press the F8 key) through the code, to see what is actually being passed?

AW
0
 
LVL 4

Expert Comment

by:cavehop
ID: 12242093
Try using Cboaccountname.Text instead of Cboaccountname.Value.

--Lance--
0
 

Author Comment

by:Goels
ID: 12246817
Hi All,

I tried using cboaccountname.Text but i get an error sayin that 'You can't reference a property or method for a control unless the control has the focus'.
Using cboaccountname.Value what happens is that instead of the value withing cboaccountname i.e say Microsoft getting passed the position of this record in the table i.e say if it is record no. 2, 2 gets passed.

Chow
Goels
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Goels
ID: 12247341
Hi all,

I have solved the issue of  cboaccountname.Value not showing the requisite value. What happens is that by defult it takes the value in column 0 which is the primary key value. So we have to give the statement as :

…..+ cboaccountname.Column(1)+…

Now it will pass the account name which the user has selected.

The issue that remains is when now I click on the ‘display report’ button  an MS Office pop-up box opens which says ‘Are you sure you want to open the file. It might have virus etc..so on’. Now if I click the ‘OK’ button on this pop-up box everything is fine and the report opens. But if I click on the ‘Cancel’ button I get an error saying:

Run-time error ‘16388’

The hyperlink cannot be followed to the destination.

What I am not able to get is where does this pop-up box come from when I have not included it in my code. Also if it is an embedded property of ‘Follow.Hyperlink ‘ how can I then stop the error box opening using VBA when I click on ‘Cancel’ button on the MS Office pop-up box.

Cheers
Goels
0
 

Author Comment

by:Goels
ID: 12247735
Hi all,

I have acheived the requisite using:

On Error GoTo Err_Close_Button_i_Click

.
.
.

Err_PDF_Display:
If Err.Number = 16388 Then
Resume Next

Chow
Goels
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12471841
PAQed, with points refunded (250)

modulo
Community Support Moderator
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ClickOnce Install - Shortcut Question 3 59
Fibonacci challenge 11 84
countHi challenge 25 86
endX challenge 2 50
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
A short article about a problem I had getting the GPS LocationListener working.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now