Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2007
    Posts
    33

    Unanswered: Starting Unbound Forms

    Hi all,

    Im starting with unbound forms so sorry any mistakes . I did some searches but i like to know what specialists think about and i hade some questions i cant undertand...


    I have 1 front-end, 1 form to add, 1 form to edit

    form to add: 1 buton that save data this way:
    Dim db As Database
    NIDNew = IIf(DCount("[NID]", "Table") = 0, 1, DMax("[NID]", "Table") + 1)
    Set db = CurrentDb
    Set rs = db.OpenRecordset("Table")
    With rst
    .AddNew
    !NID = NIDNew
    !Field = Me.Textbox
    .Update
    End With
    rs.Close
    Set rs = Nothing
    Set db = Nothing
    It΄s this the best way?

    To open a form to edit should i do it by the recordsource="select..." or db.OpenRecordset("Table") and then put data in controls (Me.Textbox= !Field)?

    To update a record should i go for 1 button to update and then run the code db.OpenRecordset("Table")?

    How to prevent 2 users from update same time (Error
    treatment)?


    Thx in advance

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi
    Good questions all
    Quote Originally Posted by PedroF
    I have 1 front-end, 1 form to add, 1 form to edit
    I prefer one form that can be in "edit" mode or in "add" mode.
    Quote Originally Posted by PedroF
    To open a form to edit should i do it by the recordsource="select..." or db.OpenRecordset("Table") and then put data in controls (Me.Textbox= !Field)?
    Well - if you use the former then you have a bound form. I would open a recordset using "select.. from... where..." syntax. Only bring as many records to the client as you need - no more no less. I would then populate the controls. I would normally name the controls with a convention that matches the underlying table's field names which means I can loop through the recordset and populate the controls.

    Quote Originally Posted by PedroF
    How to prevent 2 users from update same time (Error
    treatment)?
    It depends on the rules you want to use. Typically you would use "row versioning". Something like a "last_update_on" field (date\time) that you update every time a record is changed. You send this to the client with the rest of the data. Before applying any updates you check that what you sent to the client matches what is still in the table. If not someone has got in first and changed the record.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    BTW - don't use the code you posted. Use an autonumber - it is better & more idiot proof than trying to generate your own. Even if you must generate your own - you should change that code- it is very inefficient.

    Personally I prefer to use SQL statements to add & edit records rather than recordsets but that is just a preference on my part.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Jun 2007
    Posts
    33
    Ty all

    Originally Posted by pootle flump
    I prefer one form that can be in "edit" mode or in "add" mode.
    Done

    Originally Posted by pootle flump
    Well - if you use the former then you have a bound form. I would open a recordset using "select.. from... where..." syntax. Only bring as many records to the client as you need - no more no less. I would then populate the controls. I would normally name the controls with a convention that matches the underlying table's field names which means I can loop through the recordset and populate the controls.
    Roger that

    Originally Posted by pootle flump
    Something like a "last_update_on" field (date\time)
    I would never think of that... ty...

    Originally Posted by pootle flump
    Personally I prefer to use SQL statements to add & edit records rather than recordsets
    ty again...

    Now i'm going to start my own odyssey in unbound forms

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by PedroF
    ....Now i'm going to start my own odyssey in unbound forms
    way to go.. plain vanilla Access (ie using the access form & report designers) will get you a long way down the route of app design, however ultimately its a cul de sac / dead end.. you have to back out and use unbound forms if you want you app to support many concurrent users,
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Jun 2007
    Posts
    33
    Originally Posted by healdem
    if you want you app to support many concurrent users,
    yep... that's my problem... not yet but is better being prepared...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •