Results 1 to 3 of 3

Thread: Open database form to next after last one.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    19

    Question

    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

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Location
    Holden Beach NC
    Posts
    85
    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    19

    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
  •  



Click Here to Expand Forum to Full Width