Solved

InputBox giving type mismatch.

Posted on 2014-04-27
7
368 Views
Last Modified: 2014-04-27
I post on a website often and I sometimes like to use appropriate quotes depending on the topic. So what I want to do is get the quote and author already prepped for HTML posting. I have them stored in an Access DB.

The quick and easy way should be just putting the default of an InputBox and copy from there. But it errors out on the InputString = InputBox(Msg, Title, OutputString) as 13:  Type mismatch.

Any ideas?


Private Sub PrepQuote_Click()

Dim Quote As String
Dim Author As String
Dim OutputString As String
Dim InputString As String
Dim Msg As String
Dim Title As String

Quote = CStr(Me.QuoteStrTxtBox.Value)
Author = CStr(Me.AuthorTxtBox.Value)

OutputString = CStr("<i>" & Quote & "</i> -- " & Author)

Msg = "HTML formatting"
Title = "Quote"

InputString = InputBox(Msg, Title, OutputString)

End Sub

Open in new window


The OutputString looks like
<i>To be amused by what you read - that is the great spring of happy quotations.</i> -- C. E. Montague

Open in new window

0
Comment
Question by:Jim P.
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40026388
I see nothing wrong with the codes...

try a compact and repair then debug>compile

check if you have missing references.

also, try commenting the whole Private Sub PrepQuote_Click() codes, then do  a Debug > compile, see if there are other errors.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40026390
I copied the codes to a module

Sub PrepQuote()

Dim Quote As String
Dim Author As String
Dim OutputString As String
Dim InputString As String
Dim Msg As String
Dim Title As String

Quote = "To be amused by what you read - that is the great spring of happy quotations."
Author = "C. E. Montague"
OutputString = CStr("<i>" & Quote & "</i> -- " & Author)

Msg = "HTML formatting"
Title = "Quote"

InputString = InputBox(Msg, Title, OutputString)

End Sub

Open in new window



and I got this

x
0
 
LVL 38

Author Comment

by:Jim P.
ID: 40026398
Hey Ray (cap),

I re-tried the compile and C&R and am still getting it. It's an Acc2k7 with SP's installed.

I've attached it. This is irritating to me.
Quotes.zip
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 40026410
The problem is that you have a control on the form with the name InputBox.

You need to change that or use this.
InputString = VBA.InputBox(Msg, Title, OutputString)

Open in new window

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40026414
test this
Quotes.accdb
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40026416
imnorie is correct, sorry did not see your post.

anyway, I changed the name of the textbox "InputBox"
0
 
LVL 38

Author Closing Comment

by:Jim P.
ID: 40026431
Slap me for a stupid mistake. I forgot it was a keyword.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

730 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