|
-
Oct 21st, 2000, 09:49 AM
#1
Thread Starter
Junior Member
I'm working on a vb front end for a jet 4. database and I want the entry form to open to a blank line in the database after the last entry. Any ideas?
Bill
-
Oct 21st, 2000, 10:13 AM
#2
Lively Member
Originally posted by deadalus1
I'm working on a vb front end for a jet 4. database and I want the entry form to open to a blank line in the database after the last entry. Any ideas?
Bill
Deadalus1,
The best answer is to use unbound controls and then some event to trigger an insert routine. For example you might have three Text controls on a form that indicate FirstName, LastName and CompanyName. The user enters the data and then clicks on a command button that says "Add Customer". The code in the Command Button should: 1) Validate the data. 2) Insert the new record, or prompt the user for Valid Data. To Handle the insert in DAO you should probably create a global WorkSpace and DataBase and then you can access the Database from anywhere in code.
In your Global Declarations Place The Following:
Dim WS as WorkSpace
Dim db As DataBase
In Your FormLoad Event of your main form or in your SUB Main Place the Following:
Dim dbDir as string
dbdir=DatabasePath & DatabaseName
Set Ws = DBEngine.Workspaces(0)
Set Db = Ws.OpenDatabase(DbDir)
In Your AddNew Event Handler (Command1_Click) Place the following:
Dim txtSQL as String
'Put your data validation code here
txtSQL = "INSERT INTO TableName( FieldName1, FieldName2, FieldName3 ) "
txtSQL=txtSQL & SELECT "
txtSQL=txtSQL & Chr(39) & Text1.Text & Chr(39) & ", "
txtSQL=txtSQL & Chr(39) & Text2.Text & Chr(39) & ", "
txtSQL=txtSQL & Chr(39) & Text3.Text & Chr(39) & ";"
db.execute Sql
Hope this helps
Hunter
-
Oct 21st, 2000, 11:19 AM
#3
Thread Starter
Junior Member
Thanks Hunter.
I'm going to give that a shot right now. Sound like exacly what I'm after.
Bill
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|