I have a form with 3 textboxes, combo1, and 5 option buttons, what i would like to do is save the info into a database.
Inside the database there is 7 fields - but for now i would like to just save 5 to the database:
Name | Qty | Status | Type | Spice
i have a module called "ModData" and in it is the following, but i really don't know how to use it..
Code:
Public db As Database
Public rs As Recordset
Public ws As Workspace
Public Function InitDB(TableName As String, DataFile As String, DataIndex As String)
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase(App.Path & "\" & DataFile)
Set rs = db.OpenRecordset(TableName, dbOpenTable)
rs.Index = DataIndex
End Function
Public Function SelectData(TableName As String, TableCol As String, TheData As String)
Set rs = db.OpenRecordset("SELECT * FROM " & TableName & " WHERE " & TableCol & "='" & Replace$(TheData, "'", "''") & "'")
End Function
but i have seen it used to save data into a database like:
i honestly do not have the time to learn something new and that in depth like that at this time - especially knowing this project has to be done and ready monday morning.. all i want to do is save 4 pieces of info into an access db and then read those 4 back on the main form.
i looked in the other program and DAO 3.6 was checked in the project/reference.. not ADO
but i don't understand either/or.. so..
Last edited by elRuffsta; Sep 15th, 2014 at 11:06 AM.
I'd recommend to use ADO instead of DAO when dealing with MDBs (simply more examples).
Have a look at the two simple Demos below - they include a small Helper-Module,
which makes it easy to deal with *.mdb Files per ADO (including creation of an entire new DB-File,
creation of Tables and the appropriate Fields etc.)
thanks for the links to the tutorials, but i guess one would really have to see how i built my app so they could help me finish it the way i envisioned it.. simply because i put some time and effort into it and i really really don't want to change it or re-do it over again.
so if there is someone that is willing to work with me one on one with it so that it can finally be finished (there isn't much left at all to do to it honestly).. let me know.
Last edited by elRuffsta; Sep 15th, 2014 at 11:07 AM.
The Q&A forums don't work well for blow by blow coding assistance, and when people try it we end up with "neverending story" threads that go on for 40, 60, 100 posts - and the result seldom has any content useful to anyone who comes by later. These forums work best for questions with reasonably finite answers.
It sounds like you need one-on-one help, and the place to request that sort of assistance is probably the Project Requests forum. Once you have a volunteer or two you can coordinate through a project thread in the related Project Communication Area.
While some members like to dodge the rules and do that sort of thing right here and the moderators have been amazingly tolerant of this misbehavior in recent years, this isn't really the forum for that sort of thing.
that's not what i am saying or asking... i am asking for help to save data to an access database.. but i already built my program, and so far nothing that has been said helps me right now and the best way for someone to help me is to actually see my program.. that doesn't mean i want everybody to see it.. i think one person would be enough to see and have access to my program..
if you ask me, that is fair.. my program is done.. just the database part is all that i need help with..
Last edited by elRuffsta; Sep 15th, 2014 at 11:08 AM.
My advice would to find examples showing how to save using the different method and figure out which you want to use. One method is that which the example here uses.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
that's not what i am saying or asking... i am asking for help to save data to an access database.. but i already built my program, and so far nothing that has been said helps me right now ..
Sorry, but that is not true - everything that was said would help you, if only you'd be willing to invest some time...
And what you wrote in your post #3:
i honestly do not have the time to learn something new and that in depth like that at this time - especially knowing this project has to be done and ready monday morning.. all i want to do is save 4 pieces of info into an access db and then read those 4 back on the main form.
comes across quite impatient - aside from that, saving your "4 pieces of info into an access-db"
is definitely *not* rocket-science - especially not, when you would at least take a look at the Demo-Links -
and incorporate the (ADO-based) helper-module into your App.
There's everything in there, what you need:
First add a reference to "Microsoft ActiveX-DataObjects..." into your Project -
and include the Module: modADODBHelper.bas into your Project-Tree.
Then, to open the DB use the Function:
OpenConn FullPathToYourMDBFile
To get an ADO-Recordset, you can use the GetRs-Function which is also available in that module:
Dim Rs as ADODB.Recordset
Set Rs = GetRs("Select * From YourTable Where ...")
To add new values, simply use the sequence you already included in your first posting
(in case your Select above really contains all the Fields you used below):
rs.AddNew
rs("Game Name") = Text1
rs("Company") = Text2
rs("Year") = Text3
rs("Cartridge ID") = Text4
rs("Rarity") = Combo1.Text
rs("Own") = Text5
rs("Qty") = Text6
rs("Notes") = Text7
rs("Value") = Text8
rs("Label") = Text9
rs.Update
I can't really see, how that can take longer than - say - half an hour -
or in case you're really new with that - maybe you will need three hours
(to study a bit - and experiment for two hours first).
If it is not possible for you, to adapt your program (with the help of the already
mentioned modADODBHelper.bas) over the remaining Sunday - then you're
perhaps in the "wrong profession" - or much, much too impatient, nervous, whatever...
The regulars here don't like it very much, when one tries to "put on some pressure"
by mentioning ones own, private deadlines - at least not, when there's no decent
efforts detectable, that you "hang into it", trying to solve the problems on your own.
So, in your further communication with this board here, you should describe clearly, what
you tried (including some info, what your current Table-Definitions in your DB look like,
including the Field-Definitions/Types of the concrete Table you want to save Data into...
...accompanied by, which functions from modADODBHelper.bas you tried - and what
concrete Error-Messages you got, whilst attempting to save "your 4 pieces of Info".
As said - all that doesn't sound very complicated, and should be solved very easily,
if only you'd describe your current problems as clearly as possible - no need to post
your whole project as a Zip - just keep up a polite dialogue - without putting up any
more pressure - and you will get help.
@ elRuffsta
first:
a word of warning: if you do not know what you are doing, then do not do it
second:
i never thought i was going to say, what i am going to say
there is an extremely easy solution to your problem,and it is on the vb toolbox : the DATA CONTROL
use it with bound textboxes and it will allow you to do what you want without any programming
a quick course: http://www.vb6.us/tutorials/database...ntrol-tutorial
disclaimer:
if you succeed in wrecking the database, i am NOT responsible
i'm getting tired of looking at tutorials because they only show listviews and such and my program doesn't require or need any of that stuff.
my main form has 72 buttons.. why? you ask.. because it's a seed tray helper and the buttons are lined up accordingly: Attachment 118747
so now you add an entry by clicking one that says "Empty":
end result.. is the button you selected is where you planted a seed hence that button will hold the entry for seed: Attachment 118751
then you can access/edit/delete that seed through it's entry form by pressing the one you want:
show me a tutorial that has buttons in it like the way i wanna do it and i'll be all over it.. the listview stuff just confuses me and it's not what i'm looking for. until then, this is where i'm stuck.. like i said the app is done really.. some small tweaks still.. but i can do all that "after" the database is working with this.
Whilst your ScreenShots above deliver some background-info - what we are more interested in
is your current DB-layout - as already requested a few postings further above:
"... you should describe clearly, what you tried (including some info, what your current Table-
Definitions in your DB look like, including the Field-Definitions/Types..."
From you ScreenShot it becomes clear, that the problem apparently needs something like a Table:
[Trays] with Fields like (TrayID, TrayName, MaxFieldsInTray, etc.)
and of course a Table:
[Seeds] with Fields like (SeedID, SeedName, PlantType, ClimaticType, etc.)
And then a Table, which brings the Record-IDs of Table [Trays] together with the entries in
Table [Seeds] - e.g. a simple "combined-name" might do like:
[TraysSeeds] with Fields (TrayID, SeedID, PositionWithinTray, QuantityInTray, DatePlanted)
A *fully* populated Tray (with a certain ID), will cause 72 *additional* entries in your Table
[TraysSeeds]:
i can add more later if need be, but for now that's pretty much it.. as far "trying" anything.. everything i have looked into is listviewbased and their coding did not help me so i really haven't "tried" anything because it's all confusing.
max entries allowed is 72, as you delete a record - then the spot becomes available because it goes back to "Empty"
because there has to be an "Empty" spot to "add" an entry - so, no you cannot actually have an additional 72 spots..
why would you need a tray ID if there is only one tray? unless i were to let the user have more than 1 tray and they could pick which tray they wanna deal with... but that would be like version 2.0 of the program lol.
Last edited by elRuffsta; Sep 15th, 2014 at 11:10 AM.
i'm getting tired of looking at tutorials because they only show listviews and such and my program doesn't require or need any of that stuff.
did you read the tutorial i gave you a link to ?
does it even mention listviews ???
so stop whining and apply what you learned there to your seed tray
after all, every button on your form is just a key to a record in your database
and if, (as i think) you have no idea, exactly what a database,table,record,field is
then here is an other tutorial that uses random acces files http://www.vb6.us/tutorials/working-...ccess-files-vb
i hope that, at least the buttons on your form are a button array ?
maybe it would be not a bad idea at all if you would put your database here
i can add more later if need be, but for now that's pretty much it.. as far "trying" anything.. everything i have looked into is listviewbased and their coding did not help me so i really haven't "tried" anything because it's all confusing.
That link is invalid and so is the one you sent me via private message. If possible please upload the project to the thread.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
and if, (as i think) you have no idea, exactly what a database,table,record,field is
first, thank you for the links.. i do look at them
secondly, please do not "assume" anything of what i do or do not know.. i have made websites, owned an online mafia game, made ds games, some pc games/software, currently working on my first phone app..
i don't judge anyone here, with that said.. i ask the same in return ok? i just haven't dealt with with access databases.. i have done textfiles tho.
so therefore, you are incorrect with your thoughts and statement about me.. i don't expect an apology... but please do not mis-judge me again in your future posts.. thank you.
Last edited by elRuffsta; Sep 15th, 2014 at 01:59 PM.
Guess what some have said, you are a bit impatient....Access DBs are EASY to use....here is a small example of how to take your information and save to a table in an Access DB. Pretty self-explanatary.
So what IS? In your OP, you stated "but for now i would like to just save 5 to the database.", ,and in post #9, you again said: "i am asking for help to save data to an access database"....
So we speaking for handling the form status, and maybe that status in later weeks come bigger, with some more individual control states.
The better way it to use memo as field type, and feed it wit a string of a series of controlname/statevalue
So to get the status is an easy walking of controls reading the type first and then convert the value to string.
To recreate the state of the form just read the memo and put all controls in one of two possible ways:
One way is to ask for value (ask means search proper the string as loaded from memo field), because the order of the setting have rules to comply. The other way is the easy one, you set the control as first to saved first to set.
A more easy way is to work only with an string array, and forget the database..., just save the "lines"...
it's a project that requires us to use an access database..
I assume you were given the database mentioned in post #18 by someone else and now have to create the code to load the info into your program and save the info back to the database yourself? Could you please upload the exact database you are using?
Edit:
Forget about that request! I just noticed you included the database in the zipped project you sent me.
Last edited by Nightwalker83; Sep 18th, 2014 at 08:11 PM.
Reason: Adding more!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
You know it really is not very hard at all to work with an Access DB from VB.
Even in your first post above you have code that could do the job. It is DAO and would be better to do ADO but one would think that it would take less than 30 minutes for a novice to adapt that code to suit your needs.
I remember when I first came into contact with Access I had never used any DB engine before, all data had been saved in text files, binary files and/or RA files. Within a couple of hours I was able to handle the basics of reading and writing to Access DBs through code and even simple SQL select, update, insert and delete statements. Of course it took a bit more time to come to grips with the more complex Joins, grouping and such.
VB even includes a wizard that will allow you to create a form with data access that can read, edit, add, delete data from an Access db without writing a single line of code so it really isn't hard if you try
@elRuffsta if you are going to use a database with your project you MUST plan how you want to use it in the project. The project you sent me has fields on the "Add" form which, are not in the in the database. That being said there is no point having those fields on the form, unless, you would like me to add those fields to the database?
Edit:
Here is the project with the database implement! I tried adding rs.find to automatically locate and load existing records into the program. However, the database kept say there was a conflict between records when searched by ID. Although , this was the same method I used in an example but in the example it worked.
Last edited by Nightwalker83; Sep 19th, 2014 at 02:28 AM.
Reason: Adding more!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
@elRuffsta if you are going to use a database with your project you MUST plan how you want to use it in the project. The project you sent me has fields on the "Add" form which, are not in the in the database. That being said there is no point having those fields on the form, unless, you would like me to add those fields to the database?
yeah, i hadn't got to adding those yet.. well "spice" would be the option buttons on the "Add" form.. it's still a lil buggy, is there a real need for ID's? if so, it should do it automatically - meaning we shouldn't have to give it one.. 72 buttons.. 72 = id's.. so whichever "Empty" button you click on, the "Add" or "Entry" form is assigned to that ID automatically. i made 1 record, i didn't give it an ID.. so i decided to try adding another record but when i did, it replaced the first record. - Same result when i did give it an ID.
btw, i did plan it out how i wanted to use it.. post #13
if whatever seed button you click on says "Empty", then the "Add" form appears and you "add" to that specific button you clicked on.. otherwise the "Entry" form appears and gives you the info about that seed.
so, the very first button would be automatically assigned to record 1 and the very last button would automatically be assigned to record 72 - everything in between set accordingly. when you "delete" a seed through it's entry form, that button and record becomes "Empty" and available again... holding it's ID.
It won't show that on the buttons, it will show the names as we have it - just showing how each button should work with the database without assigning ID's on the "Add" form. basically there would be no need for that ID textbox you put there.
Last edited by elRuffsta; Sep 19th, 2014 at 10:17 AM.
The ID textbox was meant to be a user defined Primary Key for the database so you could distinguish to "Cayanne Pepper" entries, from one another.
Edit:
How does the program know which database entry belongs to which button? I can not find the code which shows this connection?
Last edited by Nightwalker83; Sep 19th, 2014 at 08:48 PM.
Reason: Adding more!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
How does the program know which database entry belongs to which button? I can not find the code which shows this connection?
exactly! lol that's why i can't figure it out.. i guess you would have to assign them in the module or if hard coded, then in the main form/add form/entry form????
only thing i can come up with something like this:
Code:
Public Function SelectData(TableName As String, TableCol As String, TheData As String)
Set rs = db.OpenRecordset("SELECT * FROM " & TableName & " WHERE " & TableCol & "='" & Replace$(TheData, "'", "''") & "'")
End Function
exactly! lol that's why i can't figure it out.. i guess you would have to assign them in the module or if hard coded, then in the main form/add form/entry form????
What! Isn't this your program and you do not know how you made it work that way?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
@elRuffsta
you, ofcource, realize you are trying to solve a problem,that already has been solved by millions of happy seed tray users all over the world
are you really trying to make these happy users unhappy, by making something that is extremely simple, extremely difficult, and in every way in contradiction with itself ?
i see there is a property 'quantity' ?
so the user can put more than 1 seed in each slot of the seed tray ?
what if the users is putting say, seeds of 3 different plants in 1 slot,how are you going to solve that ?
and, if the user realizes the programmer has not thought for one microsecond about the problem he/she is trying to solve
and dicides to only put seeds of 1 kind of plant in each slot,then he/she realizes he/she has to plant them all on the same day,for there is only 1 date per slot
further more he/she realizes they have to be miracle seeds,for they all have to be transplanted/sprouted/died at the same time ?
also they all have to be of the same type mild or sweet or hot or whatever
about your 'database',well i wont even start to say whats wrong with that,would take way to long
but what i will say:
it is extremely impolity and extremely rude to contact a participant in a forum in person
to conclude:
i am completely willing to help you with whatever you want, i am even willing to write your program for you
on 1 condition:
show me that you can think, show me the system analysis you did before you decided to solve the seed tray problem
and above all: keep it in the group
to conclude:
i am completely willing to help you with whatever you want, i am even willing to write your program for you
on 1 condition:
show me that you can think, show me the system analysis you did before you decided to solve the seed tray problem
and above all: keep it in the group
Same here! It is easier if he just replies to the thread then whomever can help can reply to the thread rather than having to send private messages back and forth all the time. Having send that I have forgotten what he send in his last pm? I didn't really read it!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
@elRuffsta
you, ofcource, realize you are trying to solve a problem,that already has been solved by millions of happy seed tray users all over the world
are you really trying to make these happy users unhappy, by making something that is extremely simple, extremely difficult, and in every way in contradiction with itself ?
say what? first off there are worse programs out there than a seed tray helper.. i rather use an app than write things down on paper to keep track or taping pieces of paper to each slot. i don't judge your programs or anyone else's - so please show me the same courtesy and not judge mine..thank you.
i'm not gonna get into it with you - the app was intended for 1 seed per slot, i started to realize that some people do actually plant up to 2-3 seeds per slot (incase 1 doesn't sprout), that's why i put the qty in there.. anyways, i removed the quantity parts from the add form, entry form and database. the app is now for 1 seed per slot as intended. but if i really really wanted to, i could have designed for more than 1 seed per slot..
btw, you do not mix seeds in a single slot unless you are planting a flower bouquet.. vegetable seeds and shrubs/trees are never mixed..
i am completely willing to help you with whatever you want, i am even willing to write your program for you
i don't need anyone to write my program(s), i just need help making it work with the database..
furthermore, if you were willing and could actually do it - you would have already done so. The only person here who has even attempted to do has been nightwalker83!
Last edited by elRuffsta; Sep 20th, 2014 at 07:57 AM.
first off it wasn't person, it was through PM - there is the option to send PM's
What IkkeEnGij is saying is that you SHOULD post your questions/replies in the thread instead of using the private message system. The private message system is NOT meant to be use as a way to communicate with other forum members just to get help on your coding projects. It is MEANT for members to contact eachother when the topic of discussion is not suitable for public discussion.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
@elRuffsta
quite an extensive edit you did to your post he
could it be that maybe you are beginning to show a sparkle of understanding
but since there is at least 1 person that has read your unedited post
and therefore know what nonsence you posted
however i had my responce to your unedited post allready
and i am NOT going to change it
so here goes:
so you know HOW you want your program to work ?
maybe you could tell us ?
from what i have seen so far, none of the millions happy seedtray users world wide, will be able to do with your program, what
they do right now in an extremely simple way
but please tell us how you want your program to work
maybe you could start with explaining us how you are going to do the following:
yesterday i planted 2 pepper seeds in slot #1 of the seedtray
2 different kinds of pepper,1 mild,1 hot
today i plant another pepper in slot #1 , an extra hot kind
how are you going to record that ?
2 weeks from now, i see 1 has germinated ,how are you going to record that? and wich one
3 weeks from now , all have germinated
4 weeks from now , the mild one has died
5 weeks from now i decide to transplant the hot one
and so on....
how are you going to record all that ?
as far as i can see there are 2 options
1)the extremely easy...do what all the millions happy seedtray users world wide are doing right now
2)the somewhat less easy...make your database truly relational
judging by what you have done so far option 2 is totally beyond your capabilities
so judge by yourself
to conclude:
PLEASE,PLEASE,PLEASE tell us how you want your program to work
now for your extensively edited post
so now you are trying to make a program that NOBODY in the entire world has any use for ?
NOBODY in the entire world except you yourself maybe
for after all,if there is no need to record the history of a seed why have a program to do it