By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,566 Members | 1,779 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,566 IT Pros & Developers. It's quick & easy.

HELP Please! Type mismatch error

P: n/a
Hi there!

Please help me out here. I am an inch away from completing my
assignment.

I am very new to VBA but i have very less time to be efficient at it.

I am getting a type mismatch error when i click the button whose code
is:

Private Sub cmdOpen_Click()

'Open PDF

Dim Company_Name As String
Dim PurchaseOrder As String
Dim FilePath As String
Dim value As Integer

Me.Refresh

Text23.SetFocus
Company_Name = Text23.Text

PONo.SetFocus
PurchaseOrder = PONo.Text

FilePath = "G:\Customer Services\Purchase Orders\" & Company_Name & "\"
& PurchaseOrder

value = fHandleFile((FilePath), WIN_NORMAL)

End Sub
fHandleFile is a function which has to open up a pdf file.

The code for this function is this:

http://www.mvps.org/access/api/api0018.htm
Please help me here....i dont think is a big problem. :)

Regards,

-Rehan

Sep 22 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Your variable called value is an integer value, whereas the function
fHandleFile looks to be evaluating to a String. That's why you are
getting the type mismatch.

Just FYI:
Your code can be simplified like this.

Private Sub cmdOpen_Click()

'Open PDF

Dim FilePath As String
Dim value As Integer

Me.Refresh

FilePath = "G:\Customer Services\Purchase Orders\" & Me.Text23 & "\"
& Me.PONo

value = fHandleFile((FilePath), WIN_NORMAL)

End Sub

It is also a good idea to name your form fields meaningful names, not
Text23. I believe you will be glad you did in the long run. You will
probably need a file extention in your file path as well, .pdf perhaps.

Hope that helps!

Rehan wrote:
Hi there!

Please help me out here. I am an inch away from completing my
assignment.

I am very new to VBA but i have very less time to be efficient at it.

I am getting a type mismatch error when i click the button whose code
is:

Private Sub cmdOpen_Click()

'Open PDF

Dim Company_Name As String
Dim PurchaseOrder As String
Dim FilePath As String
Dim value As Integer

Me.Refresh

Text23.SetFocus
Company_Name = Text23.Text

PONo.SetFocus
PurchaseOrder = PONo.Text

FilePath = "G:\Customer Services\Purchase Orders\" & Company_Name & "\"
& PurchaseOrder

value = fHandleFile((FilePath), WIN_NORMAL)

End Sub
fHandleFile is a function which has to open up a pdf file.

The code for this function is this:

http://www.mvps.org/access/api/api0018.htm
Please help me here....i dont think is a big problem. :)

Regards,

-Rehan
Sep 22 '06 #2

P: n/a
"Rehan" <mr*******@gmail.comwrote in
news:11*********************@b28g2000cwb.googlegro ups.com:
Hi there!

Please help me out here. I am an inch away from completing my
assignment.

I am very new to VBA but i have very less time to be efficient
at it.

I am getting a type mismatch error when i click the button
whose code is:

Private Sub cmdOpen_Click()

'Open PDF

Dim Company_Name As String
Dim PurchaseOrder As String
Dim FilePath As String
Dim value As Integer

Me.Refresh

Text23.SetFocus
Company_Name = Text23.Text

PONo.SetFocus
PurchaseOrder = PONo.Text

FilePath = "G:\Customer Services\Purchase Orders\" &
Company_Name & "\" & PurchaseOrder

value = fHandleFile((FilePath), WIN_NORMAL)

End Sub
fHandleFile is a function which has to open up a pdf file.

The code for this function is this:

http://www.mvps.org/access/api/api0018.htm
Please help me here....i dont think is a big problem. :)

Regards,

-Rehan
from the code at mvps, this line
fHandleFile = lRet & _
IIf(stRet = "", vbNullString, ", " & stRet)
tells me you need to change the declaration (Dimstatement) of
value to Variant
--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Sep 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.