Alpha Video Training
Results 1 to 12 of 12

Thread: if a client doesnt exist open client form

  1. #1
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,419

    Default if a client doesnt exist open client form

    I have been trying different versions of this script and just can't seem to get it to work only when the client does not exist, it fires even if it does exist.

    this is in the canwritefield event on my quote to table

    Code:
     
    if exist(A_Field_value,"clients","Long_Name") then
     ' do nothing
    else
     form.view("clients")
     :clients.new_record()
    end if
    can anyone point me in the right direction, please.

  2. #2
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,946

    Default

    try this:
    temp=a_field_value
    msgbox("","" + temp)
    end

    then write down exactly what the value is, and then go to the clients form, and verify that there is in fact a record exactly matching that value

  3. #3
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,419

    Default

    Thanks Martin,

    but as expected this only shows that what I am entering does exist as the field I am typing into is a dropdown lookup to the client longname field.

    what i want to do is if not in the drop down list open the clients form and enter a new one. maybe there is anolther way of doing this?

  4. #4
    "Certified" Alphaholic Scott Emerick's Avatar
    Real Name
    Scott Emerick
    Join Date
    Dec 2000
    Location
    Central Virginia/ North Carolina Border
    Posts
    2,154

    Default

    Lance,

    Check your code in the interactive window replacing A_Field_value with something you know is or is not there

    ?exist("FOO","clients","Long_Name")
    =.f.

    My guess is that you need to use alltrim() in your index.

    Scott

  5. #5
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,419

    Default

    Scott,

    This also presented expected results "FOO" = .F. , "Lance Gurd" = .T. without needing a trim. Still stuck!

  6. #6
    "Certified" Alphaholic Scott Emerick's Avatar
    Real Name
    Scott Emerick
    Join Date
    Dec 2000
    Location
    Central Virginia/ North Carolina Border
    Posts
    2,154

    Default

    Hummmmm .. What happens if you use this.value instead of a_field_value?

    if exist(this.value,"clients","Long_Name") then

  7. #7
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,419

    Default

    the same thing, enter a valid name, client form still opens!!!!

  8. #8
    "Certified" Alphaholic Scott Emerick's Avatar
    Real Name
    Scott Emerick
    Join Date
    Dec 2000
    Location
    Central Virginia/ North Carolina Border
    Posts
    2,154

    Default

    Just for the heck of it move your code to the onwrotefield event and see if it works when you depart the field.

  9. #9
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,419

    Default

    With this.value as the key value it worked when I put it in the onwrotefield,

    thanks Scott.

    Anybody know why it didn't work the other way?

  10. #10
    "Certified" Alphaholic Scott Emerick's Avatar
    Real Name
    Scott Emerick
    Join Date
    Dec 2000
    Location
    Central Virginia/ North Carolina Border
    Posts
    2,154

    Default

    Not that this is the answer to this situation, but what I have seen in the past is that the fields value does not change until it no longer has focus, so with that being said, I can see why A_Field_Value is not the current "Value".

    I guess that makes sense if you think about it.

  11. #11
    "Certified" Alphaholic Lance Gurd's Avatar
    Real Name
    Lance Gurd
    Join Date
    Jun 2005
    Location
    Southampton, UK
    Posts
    1,419

    Default

    all hale north carolina

  12. #12
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,946

    Default

    Here is code I tested from two different tables, and it works as expected. The code is in "clients" in field rules for the canwritefield event for "company" - the index name is "company", and is a simple single field index:

    Code:
    temp=alltrim(a_field_value)
    if exist(alltrim(a_field_value),"clients","company")
    	msgbox("","true " + temp)
    	f=form.view("invoices")
    	f.new_record()
    else
    	msgbox("","false " + temp)
    end if
    However - what are you going to do next? We don't have a cancel() and the first form is left in an enter mode.

Similar Threads

  1. form margins (difference between client and designer)
    By Sieward in forum Alpha Five Version 7
    Replies: 6
    Last Post: 10-19-2005, 09:06 AM
  2. Email client
    By Schulzie in forum Alpha Five Version 6
    Replies: 4
    Last Post: 07-09-2005, 03:01 PM
  3. Say No to a Client?
    By rtbtat in forum Alpha Five Version 5
    Replies: 22
    Last Post: 07-21-2004, 05:18 AM
  4. Opening a form on the current client.
    By Themis Skiathitis in forum Alpha Five Version 4
    Replies: 4
    Last Post: 05-03-2003, 11:19 AM
  5. email client
    By Chester Kylstra in forum Alpha Five Version 5
    Replies: 2
    Last Post: 12-02-2002, 11:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •