Results 1 to 2 of 2

Thread: Help!!!

  1. #1

    Thread Starter
    Addicted Member kalicki's Avatar
    Join Date
    Mar 2001
    Location
    Orlando, Florida
    Posts
    134

    Help!!!

    I am an absolute noob at DB programming. I have a DB named "disease" and the field that holds the disease is also "disease". I don' think that matters, since it works for the most part. Headache is a column, where -1 means true and 0 is false. Here is my code:

    Private Sub chkHeadache_Click()
    symptoms = symptoms & " where Headache=-1"
    End Sub

    Private Sub cmdCompute_Click()
    'Computes what diseases the user might have


    Data1.RecordSource = "Select disease from disease" & symptoms
    Data1.Refresh
    MSFlexGrid1.Visible = True
    Exit Sub
    End Sub

    I can't get it to have the condition work. I'm not very skilled at VB, so any help is greatly appreciated....

    Thanks,
    Bryan Kalciki

  2. #2
    Lively Member
    Join Date
    Nov 2001
    Posts
    89
    I have a DB named "disease" and the field that holds the disease is also "disease".
    Based on your SELECT statement, I assume that you meant you have a TABLE named "Disease" and a field named "Disease". This will work fine. I have the same situation in one of my tables.

    If you have mulitple symptoms, say Headache & Fatigue, and the Fatigue checkbox has code similar to the chkHeadache_Click code, then your symptoms variable would already have data in it and the select statment will end up not being valid. For example, if both were checked your statement would end up being this (which is wrong): (The caps is just for readibilty, nothing else.)

    SELECT disease FROM disease WHERE Headache = -1 WHERE Fatigue = -1

    What you would need is this:

    SELECT disease FROM disease WHERE Headache = -1 AND Fatigue = -1


    I'm guessing that your problem is with the symptoms variable in this code:
    VB Code:
    1. Private Sub chkHeadache_Click()
    2. symptoms = [color=red]symptoms[/color] & " where Headache=-1"
    3. End Sub

    If symptoms is an empty string, then your SQL syntax looks right, but if there is anything in that variable, then your statement will fail. You can step through your code line by line by pushing F8. When you put the mouse over a variable, a tool tip box will show up giving you the value of the variable, then you'll know what is really in there.

    Hope that helps some.
    --KSW

Posting Permissions

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



Click Here to Expand Forum to Full Width