Left Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My data contains PIN numbers where by some start with numbers e.g., 001 while
others start with letters e.g., PIN.

I have a form that will open that will open the report but its not opening
it right. I would like to open the report using either of the following
conditions
1. All
2. Only PIN numbers that start with numbers
3. only PIN numbers that start with letters PIN

This is how my code looks like:

If Me.ListPINS.Column(0) = "<All PINS >" Then
DoCmd.OpenReport strDocName, acViewPreview
ElseIf Me.ListPINS.Column(0) = "<Number PINS>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "left([PINNUM],3)" <> "PIN"
ElseIf Me.ListPINS.Column(0) = "<Letter PINS>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "Left(PINNUM, 3)" ="PIN"
End IF

Please Help!
 
JOM said:
My data contains PIN numbers where by some start with numbers e.g.,
001 while others start with letters e.g., PIN.

I have a form that will open that will open the report but its not
opening it right. I would like to open the report using either of
the following conditions
1. All
2. Only PIN numbers that start with numbers
3. only PIN numbers that start with letters PIN

This is how my code looks like:

If Me.ListPINS.Column(0) = "<All PINS >" Then
DoCmd.OpenReport strDocName, acViewPreview
ElseIf Me.ListPINS.Column(0) = "<Number PINS>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "left([PINNUM],3)"
<> "PIN" ElseIf Me.ListPINS.Column(0) = "<Letter PINS>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "Left(PINNUM, 3)"
="PIN" End IF

Please Help!

There's a problem with your attempt at quotes inside quotes. In this
case, you can easily fix it by using single-quotes inside the
double-quotes:

Select Case Me.ListPINS.Column(0)
Case "<All PINS >"
DoCmd.OpenReport strDocName, acViewPreview
Case "<Number PINS>"
DoCmd.OpenReport strDocName, acViewPreview, , _
"Left([PINNUM],3) <> 'PIN'"
Case "<Letter PINS>"
DoCmd.OpenReport strDocName, acViewPreview, , _
"Left(PINNUM, 3) ='PIN'"
End Select
 
My data contains PIN numbers where by some start with numbers e.g., 001 while
others start with letters e.g., PIN.

I have a form that will open that will open the report but its not opening
it right. I would like to open the report using either of the following
conditions
1. All
2. Only PIN numbers that start with numbers
3. only PIN numbers that start with letters PIN

This is how my code looks like:

If Me.ListPINS.Column(0) = "<All PINS >" Then
DoCmd.OpenReport strDocName, acViewPreview
ElseIf Me.ListPINS.Column(0) = "<Number PINS>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "left([PINNUM],3)" <> "PIN"
ElseIf Me.ListPINS.Column(0) = "<Letter PINS>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "Left(PINNUM, 3)" ="PIN"
End IF

Please Help!

This is comparing the literal text strings, not calling the Function.

Try

DoCmd.OpenReport strDocName, acViewPreview, , _
"Left([PINNUM],3) <> 'PIN'"

(or = 'PIN' respectively of course).

John W. Vinson[MVP]
 
Thanks alot that worked!

John Vinson said:
My data contains PIN numbers where by some start with numbers e.g., 001 while
others start with letters e.g., PIN.

I have a form that will open that will open the report but its not opening
it right. I would like to open the report using either of the following
conditions
1. All
2. Only PIN numbers that start with numbers
3. only PIN numbers that start with letters PIN

This is how my code looks like:

If Me.ListPINS.Column(0) = "<All PINS >" Then
DoCmd.OpenReport strDocName, acViewPreview
ElseIf Me.ListPINS.Column(0) = "<Number PINS>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "left([PINNUM],3)" <> "PIN"
ElseIf Me.ListPINS.Column(0) = "<Letter PINS>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "Left(PINNUM, 3)" ="PIN"
End IF

Please Help!

This is comparing the literal text strings, not calling the Function.

Try

DoCmd.OpenReport strDocName, acViewPreview, , _
"Left([PINNUM],3) <> 'PIN'"

(or = 'PIN' respectively of course).

John W. Vinson[MVP]
 
Thanks alot that worked!

Dirk Goldgar said:
JOM said:
My data contains PIN numbers where by some start with numbers e.g.,
001 while others start with letters e.g., PIN.

I have a form that will open that will open the report but its not
opening it right. I would like to open the report using either of
the following conditions
1. All
2. Only PIN numbers that start with numbers
3. only PIN numbers that start with letters PIN

This is how my code looks like:

If Me.ListPINS.Column(0) = "<All PINS >" Then
DoCmd.OpenReport strDocName, acViewPreview
ElseIf Me.ListPINS.Column(0) = "<Number PINS>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "left([PINNUM],3)"
<> "PIN" ElseIf Me.ListPINS.Column(0) = "<Letter PINS>" Then
DoCmd.OpenReport strDocName, acViewPreview, , "Left(PINNUM, 3)"
="PIN" End IF

Please Help!

There's a problem with your attempt at quotes inside quotes. In this
case, you can easily fix it by using single-quotes inside the
double-quotes:

Select Case Me.ListPINS.Column(0)
Case "<All PINS >"
DoCmd.OpenReport strDocName, acViewPreview
Case "<Number PINS>"
DoCmd.OpenReport strDocName, acViewPreview, , _
"Left([PINNUM],3) <> 'PIN'"
Case "<Letter PINS>"
DoCmd.OpenReport strDocName, acViewPreview, , _
"Left(PINNUM, 3) ='PIN'"
End Select

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top