INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Forms & Screen

A sample Search Form. by ramani
Posted: 7 Dec 02 (Edited 12 Dec 02)

*********************************************************
** Author : Ramani (Subramanian.G)
**          FoxAcc Software / Winners Software
**          ramani_g@yahoo.com
** Type   : Freeware with reservation to Copyrights
** Warranty : Nothing implied or explicit
** Last modified : 05 November, 2002
*********************************************************
** How to Run..
** 1. Save the following code as gsSearch.PRG
** 2. From the command window run that
**    DO gsSearch
*********************************************************
** gsSearcht.prg
*********************************************************
CREATE CURSOR test (cName C(20), email c(20))
INSERT INTO test (cName, email) VALUES ("experts","experts@Tek_tips.moc")
INSERT INTO test (cName, email) VALUES ("Dummy","dummy@dummy.moc")
INSERT INTO test (cName, email) VALUES ("ClayHead","clay@dummy.moc")
INSERT INTO test (cName, email) VALUES ("WoodBrain","wood@dummy.moc")
INSERT INTO test (cName, email) VALUES ("IronHead","iron@dummy.moc")
INSERT INTO test (cName, email) VALUES ("BigHead","big@dummy.moc")
INSERT INTO test (cName, email) VALUES ("ShowMan","showbiz@dummy.moc")
INSERT INTO test (cName, email) VALUES ("NutHead","nuts@dummy.moc")
INSERT INTO test (cName, email) VALUES ("Ramani","ramani@Tek_tips.moc")
INSERT INTO test (cName, email) VALUES ("Mike","mike@Tek_tips.moc")
INSERT INTO test (cName, email) VALUES ("Rick","Rick@Tek_tips.moc")
INSERT INTO test (cName, email) VALUES ("Chris","chris@Tek_tips.moc")
INSERT INTO test (cName, email) VALUES ("Dsumzz","dsumzz@Tek_tips.moc")
INSERT INTO test (cName, email) VALUES ("mySelf","me@Tek_tips.moc")
LOCATE

myFields = "cName,email"
=gsFindForm(myFields)
=MESSAGEBOX("You have selected :"+ALLTRIM(cName)+" : "+email, 0+16, "Eureka!")

RETURN
**************************************************
PROCEDURE gsFindForm
** The above codes are for example..
** The below code can be copied as gsFindForm.prg
** and you can call the code as shown in above or..
** DO FORM gsFindForm WITH myFields
*************************************************
** PROCEDURE gsFindForm
PARAMETERS tcFields

IF PARAMETERS() < 1
   RETURN .f.
ENDIF

PUBLIC oform1

oform1=NEWOBJECT("gsFindForm",'','',tcFields)
oform1.Show

RELEASE oForm1
RETURN
**************************************************
*-- Form:         gsFindForm
*-- ParentClass:  form
*-- BaseClass:    form
*
DEFINE CLASS gsFindForm AS form

   AutoCenter = .t.
   Height = 242
   Width = 420
   DoCreate = .T.
   Caption = "FindForm"
   Name = "gsFindForm"
   WindowType = 1
   inrecno = 0

   ADD OBJECT cmdfirst AS commandbutton WITH ;
      Top = 216, ;
      Left = 0, ;
      Height = 27, ;
      Width = 84, ;
      Caption = "\<First", ;
      Name = "cmdFirst"

   ADD OBJECT cmdprevious AS commandbutton WITH ;
      Top = 216, ;
      Left = 84, ;
      Height = 27, ;
      Width = 84, ;
      Caption = "\<Previous", ;
      Name = "cmdPrevious"

   ADD OBJECT cmdnext AS commandbutton WITH ;
      Top = 216, ;
      Left = 168, ;
      Height = 27, ;
      Width = 84, ;
      Caption = "\<Next", ;
      Name = "cmdNext"

   ADD OBJECT cmdlast AS commandbutton WITH ;
      Top = 216, ;
      Left = 252, ;
      Height = 27, ;
      Width = 84, ;
      Caption = "\<Last", ;
      Name = "cmdLast"

   ADD OBJECT cmdexit AS commandbutton WITH ;
      Top = 216, ;
      Left = 336, ;
      Height = 27, ;
      Width = 84, ;
      Cancel = .T., ;
      Caption = "E\<xit", ;
      Name = "cmdExit"

   ADD OBJECT grid1 AS grid WITH ;
      Height = 216, ;
      Left = -12, ;
      Top = 0, ;
      Width = 432, ;
      Name = "Grid1"
      DeleteMark = .F.
      HighlightRow = .T.
      ReadOnly = .T.
      ForeColor = RGB(0,0,0)
      BackColor = RGB(255,255,192)
      GridLineColor = RGB(0,0,128)

   PROCEDURE Init
      PARAMETERS tcFields
      IF PARAMETERS() < 1
         RETURN .f.
      ENDIF
      LOCAL nCount
      nCount = ALINES(laFields,tcFields,",")
      WITH ThisForm.Grid1
         .ColumnCount = nCount
         FOR I=1 TO nCount
            .Columns(I).ControlSource = laFields(i)
         ENDFOR
         .SetFocus()
      ENDWITH
   ENDPROC

   PROCEDURE cmdfirst.Click
      GO TOP
      ThisForm.Grid1.SetFocus()
      ThisForm.Refresh()
   ENDPROC

   PROCEDURE cmdprevious.Click
      IF NOT BOF()
         SKIP -1
      ENDIF
      ThisForm.Grid1.SetFocus()
      ThisForm.Refresh()
   ENDPROC

   PROCEDURE cmdnext.Click
      IF NOT EOF()
         SKIP
      ENDIF
      ThisForm.Grid1.SetFocus()
      ThisForm.Refresh()
   ENDPROC

   PROCEDURE cmdlast.Click
      GO BOTTOM
      ThisForm.Grid1.SetFocus()
      ThisForm.Refresh()
   ENDPROC

   PROCEDURE cmdexit.Click
      ThisForm.Release()
   ENDPROC

   PROCEDURE Grid1.AfterRowColChange
      LPARAMETERS nColIndex
      ThisForm.inRecNo = IIF(EOF() OR BOF(),0,RECNO())
      This.Columns(This.ActiveColumn).Text1.BackColor = RGB(255,0,0)
      This.Columns(This.ActiveColumn).Text1.DisabledBackColor = RGB(32,224,224)
      This.Columns(This.ActiveColumn).Text1.DisabledForeColor = RGB(0,0,0)
      This.Refresh()
      RETURN .T.
   ENDPROC

   PROCEDURE Grid1.Init
      DODEFAULT()
      WITH THIS
          .SetAll("DynamicBackColor", ;
            "IIF(recno(This.RecordSource)= ;
            ThisForm.inRecno,RGB(32,224,224), ;
            RGB(255,255,192))","COLUMN")
        .SetAll("BackColor", RGB(255,192,192),"Header")
        .SetAll("Alignment", 2, "Header")
      ENDWITH
   ENDPROC

ENDDEFINE
*
*-- EndDefine: form1
**************************************************
** EOF
**************************************************

Evaluate this to make others know how useful is this

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close