none
Invoice form in ms access vba (using dao) RRS feed

  • Question

  • I have to add an invoice how can I do it.
    Design of the ms access form(single form) is

    ---------Upper Area--------[this should be inserted into invoice master
    Date (suggest me)
    ShipMode (option button)
    Buyer (combo)
    Supplier (combo)
    Indentor (combo)

    ---------lower Area--------[this should be inserted into invoice detail

    Product   UnitPrice  UOM       Quantity
    (combo)     (textbox)    (combo)   (textbox)  (btnaddrow) (btndeleterow)



    (btnAddInvoice) (btnCancel)


    Please suggest me how to do it.Any code or sample like this.
    I don't know how to add new row of product e.t.c.
    Please help me as I have never done any programming in ms access before
    (Done most of web development,asp.net with c# ,jsp,and little bit of coldfusion)
    Thursday, January 19, 2006 5:42 PM

Answers

  •  

    Wow..... OK

    I don't know if you are serious about DAO or not and it's ok. Older DAO is a LOT easier to deal with than what we have today. With DAO you're a whole lot more likely to suceed.

    Here is what you want to do. I'd recommend making a small access database that you can't hurt... or make a private copy of any real access database and put it where you can work on it.

    Make a simple test project:

    Goto to Project | References

    Select COM

    Look for Microsoft DAO V3.6 library and add it as a reference. It may help to be sure you have the MDAC 2.8 library on your system and if you are running XP SP2 you do. :)

    Find some VB6 code on the net.

    You need to begin by Opening the File and creating a workspace.

    This can beasier said than done......

    I've adapted a little bit of vb6 code and I think this is what you do in VS2005.

     


            InSpec = PathSpecification & "AccessDatabaseName.mdb"
            Dim ws as object = DBEngine.Workspaces(0)             ' Create the database workspace
            Dim db as object = ws.OpenDatabase (InSpec, False, False, "MS Access;PWD=PASSWORDBLAHBLAH") ' Open the database

    You are going to have to develop your own connection string because they will be different for different databases but this is a good start.

    Next....

    Learn about table selection:

    Dim rst as Object 

    rst = db.OpenRecordset("SysUsers", dbOpenDynaset)

    Learn about things like rst.movefirst, rst.movelast  and rst.movenext and rst.eof

    "Sysusers" is the name of a table. RST is a recordset and it will have "fields" that correspond to the columns in a table.

    So you'll be able to do things like:

    Public Enum SysUsersFields

                    cUserName=0
                    cPassword = 1

    end Enum

    dim a as string = rst.fields(SysUsersFields.cUserName).value

    and voila!!! You are now reading in DAO!!!!

    To write .... set recordset fields equal to values and do a rst.update

    There you are!  DAO in a nutshell and you have enough to keep you busy for a week!

     In these samples I've used objects instead of explicit datatypes because I'm very sorry to admit that I used implicits in VB6 and I'm paying for that now. There may be explicit datatypes for these structures and if you chase them down on the net it'll be worth your while because performce will be slightly better (but probably not noticeably) so you can wait till you get to the "icing on the cake" stage before worrying about that. Also please know that everything I've done here is from memory and I likely made a few syntax errors, but the idea was to give you a quick tutorial.

    • Marked as answer by Kamran Shahid Tuesday, March 29, 2011 10:20 AM
    Thursday, January 19, 2006 6:11 PM

All replies

  •  

    Wow..... OK

    I don't know if you are serious about DAO or not and it's ok. Older DAO is a LOT easier to deal with than what we have today. With DAO you're a whole lot more likely to suceed.

    Here is what you want to do. I'd recommend making a small access database that you can't hurt... or make a private copy of any real access database and put it where you can work on it.

    Make a simple test project:

    Goto to Project | References

    Select COM

    Look for Microsoft DAO V3.6 library and add it as a reference. It may help to be sure you have the MDAC 2.8 library on your system and if you are running XP SP2 you do. :)

    Find some VB6 code on the net.

    You need to begin by Opening the File and creating a workspace.

    This can beasier said than done......

    I've adapted a little bit of vb6 code and I think this is what you do in VS2005.

     


            InSpec = PathSpecification & "AccessDatabaseName.mdb"
            Dim ws as object = DBEngine.Workspaces(0)             ' Create the database workspace
            Dim db as object = ws.OpenDatabase (InSpec, False, False, "MS Access;PWD=PASSWORDBLAHBLAH") ' Open the database

    You are going to have to develop your own connection string because they will be different for different databases but this is a good start.

    Next....

    Learn about table selection:

    Dim rst as Object 

    rst = db.OpenRecordset("SysUsers", dbOpenDynaset)

    Learn about things like rst.movefirst, rst.movelast  and rst.movenext and rst.eof

    "Sysusers" is the name of a table. RST is a recordset and it will have "fields" that correspond to the columns in a table.

    So you'll be able to do things like:

    Public Enum SysUsersFields

                    cUserName=0
                    cPassword = 1

    end Enum

    dim a as string = rst.fields(SysUsersFields.cUserName).value

    and voila!!! You are now reading in DAO!!!!

    To write .... set recordset fields equal to values and do a rst.update

    There you are!  DAO in a nutshell and you have enough to keep you busy for a week!

     In these samples I've used objects instead of explicit datatypes because I'm very sorry to admit that I used implicits in VB6 and I'm paying for that now. There may be explicit datatypes for these structures and if you chase them down on the net it'll be worth your while because performce will be slightly better (but probably not noticeably) so you can wait till you get to the "icing on the cake" stage before worrying about that. Also please know that everything I've done here is from memory and I likely made a few syntax errors, but the idea was to give you a quick tutorial.

    • Marked as answer by Kamran Shahid Tuesday, March 29, 2011 10:20 AM
    Thursday, January 19, 2006 6:11 PM
  • Kamran,

    Be aware this is not a VBA forum but for VB Net

    Maybe in this one you can find help for VBA

    http://social.msdn.microsoft.com/Forums/en-US/vbapt/threads


    Success
    Cor
    Wednesday, March 9, 2011 7:53 AM
  • I would recommend posting Microsoft Access questions to the Access for Developers forum:

    http://social.msdn.microsoft.com/Forums/en-US/accessdev/threads

     


    Paul ~~~~ Microsoft MVP (Visual Basic)
    Wednesday, March 9, 2011 3:43 PM
  • Umisha and Cor Lighert,

    It is a very very old post and i am no more interested in it


    Kamran Shahid Senior Software Engineer/Analyst (MCP,MCAD,MCSD.NET,MCTS,MCPD.net[web])
    Tuesday, March 29, 2011 10:19 AM