Results 1 to 2 of 2

Thread: Building a difficult SQL querry...(and a novice ?)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    19
    I have a couple of questions that I am hoping some of you will be able to answer. One is relatively simple and one, I believe, is relatively complex.

    Project: Developing for Access DB's b/c Access is on most computer's desktop....using VB 6.0 and using Jet 3.51.

    I have a database that I want a program to write to. I have built the forms, coded much of the project but am having trouble with the following procedure using a grsCustomers:

    Private Sub LoadRecord()
    With grsCustomers
    !DateAdded = CurrentDate
    !FirstName = txtFirst.Text
    !MiddleInitial = txtMiddle.Text
    !LastName = txtLast.Text
    End With
    End Sub

    'What is the command to update the database? The recordset?
    .Update?
    .Requery?
    I know that one is simple, but I am running into a few problems, and I am guessing it is missing syntax.


    Here is the biggie which I have been researching for quite some time. Maybe some direction to reference or some guidance starting the process would help.

    There are two databases which need to be searched: Customers and Transactions, the latter which logs a transaction number, a customer ID (which is also found in the customer table) and items purchased. They are in two different tables. There are, however, 16 fields in the search form for the customers and twelve search fields for the transaction. I am going to have to build a SQL statement on the fly for each search. If you were to look at a form with text boxes, and decide to search for customers who have a birthday within this month and have spent $100+ in the store, some of those text boxes will be blank. I need to build an SQL search query for those tables....any guidance there?

    Thank you!

    Fletcher

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    In these, rst is a bound recordset object...

    Add a record:
    Code:
    rst.AddNew
    rst.Fields("A").Value = "new item"
    rst.Fields("DifferentField").Value = 56
    rst.Update
    Edit a record:
    Code:
    If rst.RecordCount > 0 Then
        rst.MoveFirst
        rst.Edit
        rst.Fields("Value").Value = iValue
        rst.Update
    End If
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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