?
Solved

Code Adjustment

Posted on 2009-04-21
10
Medium Priority
?
281 Views
Last Modified: 2012-05-06
How can i adjust this code
str = "{DETAILS.DOCNO}='" & Trim(txtDocno.text) & "'"
Inside the Details.docno is a long number like this  042420093-0000000000011838
I want it in my code below to type txtDocno.text only the 11838 then view the report
Can i call the report using only 11838 instead of 042420093-0000000000011838 ?
Please Help!
Thanks

Private Sub Withdrawal()
Dim Report As CRAXDRT.Report
Dim str As String
    Set Report = New CrystalReport2
    str = "{DETAILS.DOCNO}='" & Trim(txtDocno.text) & "'"
    Report.RecordSelectionFormula = str
    Report.ReadRecords
    Call Report.SelectPrinter(Report.driverName, Report.PrinterName, Report.PortName)
    Screen.MousePointer = vbHourglass
    CRViewer1.ReportSource = Report
    CRViewer1.ViewReport
    Screen.MousePointer = vbDefault
    CRViewer1.ReportSource = Report
    CRViewer1.Zoom 94
    Set Report = Nothing
End Sub

Open in new window

0
Comment
Question by:Whing Dela Cruz
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 13

Accepted Solution

by:
game-master earned 300 total points
ID: 24200386


GOOD MORNING!

using the "right" function in string u can get the value u want..
sumthing like this...

str= right(details.docno,5)

this results with the value 11838


i hope sumhow i can give u idea...

game-master
0
 
LVL 8

Assisted Solution

by:Wikkard
Wikkard earned 300 total points
ID: 24200410
You just need to concatenate the 2 strings.

ie. str = "{DETAILS.DOCNO}='042420093-00000000000" & Trim(txtDocno.text) & "'"

So you only pass the last 5 digits in via textbox txtDocNo.


0
 
LVL 1

Assisted Solution

by:JosephGermanOcena
JosephGermanOcena earned 300 total points
ID: 24201214
No need to concatenate... just use the like operator...

str = "{DETAILS.DOCNO}like'%" & Trim(txtDocno.text) &  " %'"


Joseph,

Great is Jehova...
0
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.

 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 300 total points
ID: 24209616
Try it this way

str = "{DETAILS.DOCNO}='" &  right(trim(details.docno),5) & "'"

mlmcc
0
 

Author Comment

by:Whing Dela Cruz
ID: 24220093
Hi!
I tried many times but it doesn't work.
I tried this code  STR = "{DETAILS.DOCNO}='" & Right(Trim(details.docno), 5) & "'"
but a message says Object required here!
I tried the other one STR = "{DETAILS.DOCNO}like'%" & Trim(txtDocno.text) & " %'"
but no a data's appear only the form of the report.
I also tried this STR = Right(details.docno, 5) & Trim(txtDocno.text) & "'"
but a message says Object required here!
Can you tell me what to do now?
 
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 24220560
Are the errors when the report runs?

Try adding a line to see the value of the string like
MsgBox STR

or

MsgBox Right(Trim(details.docno), 5)

mlmcc
0
 

Author Comment

by:Whing Dela Cruz
ID: 24220623
Sorry, but you mean like this
MsgBox Right(Trim(details.docno), 5) & Trim(txtDocno.text) & "'"
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 24221115
That works also.

mlmcc
0
 
LVL 15

Assisted Solution

by:JackOfPH
JackOfPH earned 300 total points
ID: 24238899
okey how about this one...

str = "{DETAILS.DOCNO} like '*" & Trim(txtDocno.text) &  " *'"
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24257089
Did you try this one?
Any progress?

str = "{DETAILS.DOCNO} like '*" & Trim(txtDocno.text) &  "*'"
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

840 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