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
Printable View
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,Quote:
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
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
I'm going to give that a shot right now. Sound like exacly what I'm after.
Bill