Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memo Field is not Evaluating in Listbox List 2

Status
Not open for further replies.

carolx

Programmer
Jul 22, 2003
75
0
6
JM
lnMarketid = 0

lnReturn = SQLEXEC(oGv.pnConnhandle, 'EXEC MCRevenue.Sundries.RetrieveMarketRevenueBankTransactionsSP ?lnMarketid','bankingtransactions')
IF lnReturn = -1
=odbcerror() && Log the error
RETURN .F.
ENDIF
The 'comments' field in the table is 255 characters

ThisForm.lstSelection.RowSource = "bankingtransactions.market,bank,branchname,transactiondate,transactionamount,datelodged,marketid,routerid,lodgementid,comments"

'comments' is the memo field which evaluates to "memo"

lcComments = ThisForm.lstSelection.List(lnCnt,10) && evaluates to "memo"
IF TYPE( lcComments ) = "M" && but here the Type is not "M" (memo) so it jumps out of the routine
lnLines = ALINES( laLines, lcComments, 1 )
lcComments = ""
FOR lnLCount = 1 TO lnLines
lcComments = lcComments + laLines[ lnLCount ] + CHR(13) + CHR(10)
NEXT
ENDIF

How do I get this to work (comments to evaluate as a string)
 
Hi,

comments to evaluate as a string

Please have a look at the MLINE() and ATLINE() functions - ALINES() "copies each line in a character expression or memo field to a corresponding row in an array" (from the help file).

hth

MarK
 
Hello,

not sure on that but I think lccomments as a memoryvariable will be type "C"har.
I also recommend to check vartype instead of type.

regards
tom
 
IF TYPE( lcComments ) = "M" && but here the Type is not "M" (memo) so it jumps out of the routine

TYPE( lcComments ) will never return "M". It will always return "U". You need to put "lcComments" in quotes:

Code:
TYPE( [highlight #FCE94F]"[/highlight]lcComments[highlight #FCE94F]"[/highlight] )

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi,

Please have a look at he code below

Code:
PUBLIC go_Form

go_Form = CREATEOBJECT("frmForm")
go_Form.Visible = .T.
go_Form.Show

READ Events

CLOSE ALL 
CLEAR ALL
RETURN 

*********

DEFINE CLASS frmForm As Form
	Width = 420
	MinWidth = 420
	MaxWidth = 420
	Height = 360
	MinHeight = 360
	AutoCenter = .T.
	Themes = .F.

*********

*!*	ADD objects with their procedures

	ADD OBJECT lblComment as Label WITH ;
		Left = 12, Top = 24, Height = 36, Width = 420 - 24, AutoSize = .F., Caption = "Change text in the editbox and click on combobox" + CHR(13) + ;
				"to see the adopted changes"
		
	ADD OBJECT edtComment as EditBox WITH ;
		Left = 12, Top = 72, Width = 120, ControlSource = "csrBanks.mComment"
		
		PROCEDURE edtComment.LostFocus()
			LOCAL lcString
			lcString = ""
			
			FOR i = 1 TO MEMLINES(mComment)
				lcString = lcString + LTRIM(MLINE(mComment,i) + " ")
	
			ENDFOR 
				
			Replace csrBanks.cString WITH ALLTRIM(This.Value)

		ENDPROC 
		
	ADD OBJECT cboNames AS COMBOBOX WITH ;
		RowSourceType = 6, ;
		RowSource = "csrBanks.cString, mComment", ;
		ColumnCount = 2, ;
		ColumnWidths = "300, 48", ;
		Style = 2, ;
		Height = 24, ;
		Left = 12, ;
		Top = 174, ;
		Width = 420 - 24
		
	ADD OBJECT cmdExit As CommandButton WITH ;
    	Width = 60, Height = 30, Left = 18, Top = 318, Caption = "Exit", Anchor = 6
    	
		PROCEDURE cmdExit.Click()
			ThisForm.Release
			CLEAR Events
		
		ENDPROC
			
*!*	ADD code to form's methods

	PROCEDURE Destroy()
		ThisForm.cmdExit.Click()
		
	ENDPROC
    
	PROCEDURE Load()
		LOCAL lcText as Character
		
		lcText = "This is a " + CHR(13) + "three line " + CHR(13) + "long text" + CHR(13) + "and a ps - Bye"
		
		CREATE CURSOR csrBanks (cString C(60), mComment M)
		
		INSERT INTO csrBanks VALUES ("", lcText)
		
			
	ENDPROC
ENDDEFINE

**********

hth

MarK
 
I have tried different approaches but haven't come up with a solution. What I did eventually was to decrease the width of the comments field.

I am still interested in the solution though. If I come up with one I will post it.
 
Hi,

Why not simply use a grid instead of a listbox (see code below)?

Code:
PUBLIC go_Form

go_Form = CREATEOBJECT("frmForm")
go_Form.Visible = .T.
go_Form.Show

READ Events

CLOSE ALL 
CLEAR ALL
RETURN 

*********

DEFINE CLASS frmForm As Form
	Width = 480
	MinWidth = 480
	MaxWidth = 480
	Height = 450
	MinHeight = 450
	AutoCenter = .T.
	ShowTips = .T.
	Themes = .F.

*********

*!*	ADD objects with their procedures

	ADD OBJECT lblComment as Label WITH ;
		Left = 12, Top = 24, Height = 36, Width = 420 - 24, AutoSize = .F., Caption = "Change text in the editbox and click on the grid" + CHR(13) + ;
				"to see the adopted changes"
		
	ADD OBJECT edtComment as EditBox WITH ;
		Left = 12, Top = 72, Width = 120, ControlSource = "csrBanks.mComment"
		
		PROCEDURE edtComment.LostFocus()
*!*				LOCAL lcString
*!*				lcString = ""
*!*				
*!*				FOR i = 1 TO MEMLINES(mComment)
*!*					lcString = lcString + LTRIM(MLINE(mComment,i) + " ")
*!*		
*!*				ENDFOR 
*!*					
			Replace csrBanks.mComment WITH ALLTRIM(This.Value)

		ENDPROC 
		
*!*		ADD OBJECT cboNames AS COMBOBOX WITH ;
*!*			RowSourceType = 6, ;
*!*			RowSource = "csrBanks.cString, mComment", ;
*!*			ColumnCount = 2, ;
*!*			ColumnWidths = "300, 48", ;
*!*			Style = 2, ;
*!*			Height = 24, ;
*!*			Left = 12, ;
*!*			Top = 174, ;
*!*			Width = 420 - 24
*!*			
	ADD OBJECT grdBanks as Grid WITH ;
		Left = 12, ;
		Top = 210, ;
		Width = 480 - 24, ;
		Height = 174, ;
		Anchor = 15, ;
		HeaderHeight = 21, ;
		AllowHeaderSizing = .F., ; 
		RowHeight = 48, ;
		AllowRowSizing = .F., ;
		BackColor = RGB(0, 240, 240), ;
		ColumnCount = -1, ;
		RecordSource = "csrBanks"
		
		PROCEDURE grdBanks.Init()
			WITH This
				.Column1.Header1.Caption = "String"
				.Column1.Width = 258
				.Column1.ReadOnly = .T.

		    	WITH .Column2
		    		.Header1.Caption = "Comments"
		    		.NewObject("edtComments","EditBox")
					.CurrentControl = "edtComments"
					.edtComments.DisabledBackColor = RGB(0, 240, 240)
					.edtComments.Visible = .T.
					.Width = 150
					.Sparse = .F.
					.ReadOnly = .T.
				ENDWITH 
			ENDWITH
		ENDPROC 
		
		PROCEDURE grdBanks.AfterRowColchange()
			LPARAMETERS nColIndex
			ThisForm.Refresh()
		ENDPROC 
		
	ADD OBJECT cmdExit As CommandButton WITH ;
    	Width = 60, Height = 30, Left = 18, Top = 450 - 12 - 30, Caption = "Exit", Anchor = 6
    	
		PROCEDURE cmdExit.Click()
			ThisForm.Release
			CLEAR Events
		
		ENDPROC
			
*!*	ADD code to form's methods

	PROCEDURE Destroy()
		ThisForm.cmdExit.Click()
		
	ENDPROC
    
	PROCEDURE Load()
		LOCAL lcText as Character
		
		lcText = "This is a " + CHR(13) + "three line " + CHR(13) + "long text" + CHR(13) + "and a ps - Bye"
		
		CREATE CURSOR csrBanks (cString C(60), mComment M)
		
		INSERT INTO csrBanks VALUES ("Crédit Suisse", lcText)
		INSERT INTO csrBanks VALUES ("Deutsche Bank", "")
		
		LOCATE 
					
	ENDPROC
ENDDEFINE

**********

hth

MarK
 
A listbox can't list a memo field, only a char field.

You'd need a grid that has an editbox control in the grid column for the memo set to sparse=.f. to display a memo.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top