PDA

Click to See Complete Forum and Search --> : Building a difficult SQL querry...(and a novice ?)


FLL
Aug 18th, 2000, 08:52 PM
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

parksie
Aug 19th, 2000, 06:59 AM
In these, rst is a bound recordset object...

Add a record:

rst.AddNew
rst.Fields("A").Value = "new item"
rst.Fields("DifferentField").Value = 56
rst.Update


Edit a record:

If rst.RecordCount > 0 Then
rst.MoveFirst
rst.Edit
rst.Fields("Value").Value = iValue
rst.Update
End If