Test for 3 formats to email!

B

Bob Vance

My combo box tbEmailOption has 3 dropdown choices "ADOBE" "WORD" and
"SNAPSHOT"
Can i test to find the right format that is selected
This string is not working! ... Regards Bob

Dim strFormat As String

If Me.tbEmailOption.value = "ADOBE" Then
strFormat = acFormatPDF
If False Then
If Me.tbEmailOption.value = "WORD" Then
strFormat = acFormatRTF
If False Then
If Me.tbEmailOption.value = "SNAPSHOT" Then
strFormat = acFormatSNP
End If
 
A

Albert D. Kallal

You can open up the debug window, and then do:

? acFormatPDF

? acFormatRTF

etc. Then you can add another collum to your combo box (but set the display
length = 0 for that collum). So, base your combo box on a table.

Then, simply go:

strFormat = me.tblEmailOption.column(1)

(1 = 2nd collum, 0 = 1st collum etc).

On the other hand, you use your code with a bit of change:
Just go:

Dim strFormat As String

If Me.tbEmailOption.value = "ADOBE" Then
strFormat = acFormatPDF
end if

If Me.tbEmailOption.value = "WORD" Then
strFormat = acFormatRTF
end if

If Me.tbEmailOption.value = "SNAPSHOT" Then
strFormat = acFormatSNP
End If

The "false" you have is not defined and does nothing.

The fact that all 3 above execute is really a moot point since only one of
them can be correct.

However, for a "better" code example, you can/should use a case statemnt.

select case me.tblEmailOption.Value

case "ADOBE"
strFormat = acFormatPDF
case "WORD"
strFormat = acFormatRTF
case "SNAPSHOT"
strFormat = acFormatRTF
end select

As mentioned, the least amount of code is to add a 2nd collum to the table
that drives the combo box.

The two collums would be:

ExportType ExportText

ADOBE PDF Format (*.pdf)
WORD Rich Text Format (*.rtf)
SNAPSHOT Snapshot Format (*.snp)

The advantage of the above is that over time you can add new formats, and
not have to write/add more code. So, we might want to add a text format, and
thus we would use acFormatTXT, and get:


TEXT MS-DOS Text (*.txt)

So, each new type of export you add to the combo will NOT take additional
code....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top