?
Solved

Type Mismatch issue

Posted on 2011-10-19
13
Medium Priority
?
354 Views
Last Modified: 2013-11-27
Great Day, I have created a table that I am placing my help files in, and it has the following fields:

HelpFileID - Autonumber (KF)
HelpSubject - Text
HelpFile - Memo

On every form that has a help button, I place an unbound text box, txtHelpID that is defaulted with the number of the help file I'd like to display in a popup form. Consequently, if for example I have a help button on my customers form, when it opens, txtHelpID will have a 3 in it, since the help file in tblHelpFiles for customers has 3 as its ID. So to me, everything seems to match, but when I click the "Help" button, I get the following error message: "Text mismatch."

Here is the code that opens the popup help form:
Private Sub cmdHelp_Click()
On Error GoTo Err_cmdHelp_Click

    Dim stDocName As String
    Dim stLinkCriteria As Integer

    stDocName = "frmHelpFiles"
    stLinkCriteria = "[HelpFileID]=" & Me.txtHelpID
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    
Exit_cmdHelp_Click:
    Exit Sub

Err_cmdHelp_Click:
    MsgBox Err.Description
    Resume Exit_cmdHelp_Click
    
End Sub

Open in new window

0
Comment
Question by:yddadsjd95
  • 9
  • 4
13 Comments
 
LVL 75
ID: 36996565
What happens if you do this:


stLinkCriteria = "[HelpFileID]=" & Clng(Me.txtHelpID)

or

stLinkCriteria = "[HelpFileID]=" & Chr(34) &  Me.txtHelpID & Chr(34)

mx
0
 
LVL 75
ID: 36996576
: "Text mismatch."  or Type Mismatch ?

mx
0
 

Author Comment

by:yddadsjd95
ID: 36996596
My mistake, but it is Type Mismatch. I am still getting the same error (Type mismatch).
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 75
ID: 36996619
can you upload the db?

mx
0
 
LVL 75
ID: 36996625
And did you try this one:

stLinkCriteria = "[HelpFileID]=" & Clng(Me.txtHelpID)

mx
0
 

Author Comment

by:yddadsjd95
ID: 36996650
Yes I tried both ways. I'll send the DB to you.
0
 
LVL 75
ID: 36996661
Yes. please do ... :-)
0
 

Author Comment

by:yddadsjd95
ID: 36996746
Here it is. Thanks!

1.Open frmCustomerContactData 2. Click "Print Repair Order" 3. Click "Open Invoice" 4. Click Help
Independent-Auto---EE-10-19-2011.zip
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 36996789
ok ... found the issue  Don't Dim as Long ... see bold below


Private Sub cmdHelp_Click()
On Error GoTo Err_cmdHelp_Click

    Dim stDocName As String
    Dim stLinkCriteria   'As Long
    stDocName = "frmHelpFiles"
   
'    stLinkCriteria = "[HelpFileID]=" & CLng(Me.txtHelpID)
    stLinkCriteria = "[HelpFileID]=" & Me.txtHelpID
    DoCmd.OpenForm stDocName, , , stLinkCriteria
   
Exit_cmdHelp_Click:
    Exit Sub

Err_cmdHelp_Click:
    MsgBox Err.Description
    Resume Exit_cmdHelp_Click
   
End Sub
0
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 36996796
This also works:


Private Sub cmdHelp_Click()
On Error GoTo Err_cmdHelp_Click

    Dim stDocName As String
   Dim stLinkCriteria As String
    stDocName = "frmHelpFiles"
   
    stLinkCriteria = "[HelpFileID]=" & CLng(Me.txtHelpID)
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdHelp_Click:
    Exit Sub

Err_cmdHelp_Click:
    MsgBox Err.Description
    Resume Exit_cmdHelp_Click
   
End Sub
0
 

Author Closing Comment

by:yddadsjd95
ID: 36996924
Thank you DatabaseMX. Very few things in life give me more satisfaction than to see a problem in Access worked out. You've made my night.

Have a great rest of the evening.

Sincerely,

David
0
 
LVL 75
ID: 36996934
Always a pleasure.

I think it's because a value in at Text box is cast as ... well, text. So ... because the Dim was As Long ... there was an immediate error on that line of code - which at first I was going ... WTH ..?

So, the only thing it could have been was the Dim statement.

mx
0
 
LVL 75
ID: 36996955
In reality ... the code can be boiled down to this:


Private Sub cmdHelp_Click()

    DoCmd.OpenForm "frmHelpFiles", , , Me.txtHelpID

End Sub

Just be sure you always have something in txtHelpID.

mx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

616 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