An Access Form issue

goels

New member
Local time
Today, 12:46
Joined
Sep 16, 2004
Messages
6
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
 
goels said:
pdflink = "\\lvamfs01\shared\axysreportscreation\" + Cboaccountname.Value + cboreporttype.value + cbodate.value + ".pdf "

Are you able to use "+" symbols for concantenation in access? I've only seen this in Excel and had to use "&" in access.
 
Yes you can use "+" to concatenate in Access,

Sub Conc()
Dim s As String, f As String, g As String
s = "Bon": f = "jo": g = "ur"
Debug.Print s + f + g
End Sub

but as you see, in your own code, it can be problematic. With integers of course, they will be added, and apparently, when referencing controls, the name, not the value gets concatenated (surprise to me?).

It's always safer to use "&", then "+".

Good Luck!
 

Users who are viewing this thread

Back
Top Bottom