Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Searching A Form For Matching Records
Message
From
24/02/1999 10:46:21
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
24/02/1999 10:07:19
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00190937
Message ID:
00190950
Views:
11
>I have a table with two fields - TMS and TEC- I need to create a form that:
>1. Starts off with blank record.
>2. When user enters data in either TMS or TEC field, I need the field to check for corresponding data, (i.e TMS = AV8B TEC = AAFX and vice versa TEC = AAFX TMS = AV8B)
>3. If record does not exits add to table - with question "Do you want to add...?"
>4. The form has 4 command buttons that 3 need to be hidden until data is input into one of the fields. The four buttons are Continue, Save/exit, Cancel, and Delete. The cancel button is the only one that remains visible until data is added.
>How can i do this in the shortest possible time. I am very new at VFP and I apoligize for such a long question. Thanks in advance.
>
>jim blaylock
* Form custom method
 do case
    case !empty(thisform.tmsTxtbox.value) ;
         and !empty(thisform.tecTxtbox.value)
     locate for TMS == trim(thisform.tmsTxtbox.value) ;
          and TEC == trim(thisform.tecTxtbox.value)
    case !empty(thisform.tmsTxtbox.value)
     locate for TMS == trim(thisform.tmsTxtbox.value)
    case !empty(thisform.tecTxtbox.value)
     locate for TEC == trim(thisform.tecTxtbox.value)
    otherwise
      return .f. && No data yet - return flag
 endcase
 if eof() && No match found
     if messagebox("Add ?")=6
        insert into mytable (TMS,TEC) ;
           values (thisform.tmsTxtbox.value, thisform.tecTxtbox.value)
     else
        * Clear out TMS,TEC
        thisform.tmsTxtbox.value = ""
        thisform.tecTxtbox.value = ""
        return .f.  && Return false flag for no data
     endif
 endif
* You might bind controlsources if you wish
* do not forget to unbind when done with save/revert etc
 thisform.tmsTxtbox.controlsource = "mytable.TMS"
 thisform.tecTxtbox.controlsource = "mytable.TEC"
* Enable/disable controls
return

*Add could call custom form method

* You may add this to save/revert button
 thisform.tmsTxtbox.controlsource = "" && Unbind
 thisform.tecTxtbox.controlsource = ""
*Enable/disable controls here
 thisform.tmsTxtbox.setfocus()
Pls note that this is only a basic skeleton.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform