-
Save to database.. Please help
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:
Code:
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
-
Re: Save to database.. Please help
You may want to spend some time in the Database FAQ section
-
Re: Save to database.. Please help
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..
-
Re: Save to database.. Please help
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.)
http://www.vbforums.com/showthread.p...=1#post4645685
http://www.vbforums.com/showthread.p...=1#post4653483
Should be quite easy to adapt one of them to your 4 Fields.
Olaf
-
Re: Save to database.. Please help
links lead nowhere.. 404 on both
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
links lead nowhere.. 404 on both
Oops, sorry - corrected now in original Post #4.
Olaf
-
Re: Save to database.. Please help
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.
-
Re: Save to database.. Please help
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.
-
Re: Save to database.. Please help
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..
-
Re: Save to database.. Please help
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.
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
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:
Quote:
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.
Olaf
-
Re: Save to database.. Please 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
-
3 Attachment(s)
Re: Save to database.. Please help
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":
Attachment 118755
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:
Attachment 118753
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.
Attachment 118757 + Attachment 118747 = :thumb:
-
Re: Save to database.. Please help
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]:
Code:
TrayID, SeedID, PositionWithinTray, QuantityInTray, DatePlanted
11, 1001, 1, 5, 2014-9-11
11, 1002, 2, 3, 2014-9-12
11, 1003, 3, 12, 2014-9-11
11, 1004, 4, 7, 2014-9-14
.., ...., ., ., .........
.., ...., ., ., .........
11, 1071, 71, 9, 2014-9-14
11, 1072, 72, 15, 2014-9-11
If not all Positions in a certain Tray are populated, then there's of course no need to store
the full 72 entries in your combining table [TraysSeeds]
If you don't have something which resembles the Table-Layout I've just outlined above -
what *do* you have currently?
Without getting really concrete with the DB-related stuff (your Tables and the FieldDefs in
those Tables), it is really difficult to give advice.
Olaf
-
1 Attachment(s)
Re: Save to database.. Please help
Attachment 118777
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.
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
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
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
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.
-
1 Attachment(s)
Re: Save to database.. Please help
-
Re: Save to database.. Please help
Quote:
Originally Posted by
IkkeEnGij
i hope that, at least the buttons on your form are a button array ?
obviously.. :)
-
Re: Save to database.. Please help
Quote:
Originally Posted by
IkkeEnGij
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.
-
Re: Save to database.. Please help
ok, i give up... access db's are a pain in the a$$!
-
Re: Save to database.. Please help
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.
Hope this helps a bit.....
Attachment 118821
-
Re: Save to database.. Please help
saving is not the issue..
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
saving is not the issue..
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? What IS the issue?
-
Re: Save to database.. Please help
OH, and your Thread TITLE kinda, sorta, a teeny-bit, indicates you need help saving to a database......???
-
Re: Save to database.. Please help
it's retrieving the info correctly..
-
Re: Save to database.. Please help
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"...
-
Re: Save to database.. Please help
it's a project that requires us to use an access database..
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
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.
-
Re: Save to database.. Please help
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 ;)
-
1 Attachment(s)
Re: Save to database.. Please help
@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. :confused:
-
1 Attachment(s)
Re: Save to database.. Please help
Quote:
Originally Posted by
Nightwalker83
@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.
Attachment 118905
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.
-
Re: Save to database.. Please help
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?
-
Re: Save to database.. Please help
Quote:
Originally Posted by
Nightwalker83
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
not sure if that means anything..
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
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? :lol:
-
Re: Save to database.. Please help
@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
-
Re: Save to database.. Please help
Quote:
Originally Posted by
IkkeEnGij
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!
-
Re: Save to database.. Please help
Quote:
Originally Posted by
IkkeEnGij
@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..
Quote:
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!
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
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.
-
Re: Save to database.. Please help
@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
-
Re: Save to database.. Please help
-
Re: Save to database.. Please help
@ IkkeEnGij
first: it doesn't matter how many or to what extent i edit my post(s) - it's my right to.
secondly: i don't care who or how many people can see all the editing i have done to any of my posts - i was a mod too.. several times, so i know it can be done - bottom line is i still don't care.
thirdly: who does or does not use my app is none of your concern or anyone else's on here now is it? just sux that everone has access to my idea/program they didn't come up with on their own! that's the only part i hate..
you wanna know how i want my program to work as you said in your last post? read post #13, also look at the program i uploaded.. oh, and since you complained about contacting you in a PM.. mine is open to everyone.. i don't ***** and complain like you when someone contacts me for any reason.. unless they are rude or inappropriate.. which i wasn't! right now, yes i am being defensive because you sir are acting like a forum bully! put yer coding where your mouth is instead of letting a topic drag on since you think you know it all!!! you say it's easy? prove it!
let's end this bs once and for all.. yes, i'm calling you out on your coding skills mister know it all.. hey, you put yourself out there - so show us!
Quote:
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 you to write my program, but i am calling you out to make it work the way i want it to since you think it's so easy! or you gonna keep running your mouth and judging me, my skills and my ideas?
yeah, that's what i thought.. can run his mouth but can't back up what he says..
fourth: you have a big mouth and are very judgmental - (i laugh because guys like you don't say what they do face to face.. i do! i can back myself up in person.. i say to you on here in public view as i would to your face! i don't hide behind a pc and text tough unlike people like you)..
you say you are willing to help "even write my program", which i don't need thank you - i have coded and released several without your help in the past.. but yet you say you can.. then put your coding where your mouth is! so yes, i'm calling you out as i would face to face.
oh, and since you're not gonna help.. stay out of my topics from now on!
now we wait for his tantrum and still no proof it's as easy he says it is and without any actual help...
post over! sorry i even started the post.. helpers my a$$ - with the exception of nightwalker83 who actually did attempt. - OFFICIAL REQUEST that someone lock or delete this topic.. pointless at this point.
@nightwalker83
i won't PM you anymore since you complained about it - but i thank you for attempting to try to help..tho it was buggy - i still thank you for trying unlike unmentioned names... but you did try, i can respect that.
-
Re: Save to database.. Please help
you want me to make your program for you ?
since you refuse to tell how you want your program to work
i cannot know how you want your program to work
however i will tell you how to make a program that is usefull to the millions i was refering to
since you are using an .mdb i assume it is access before 2007
start microsoft access
make a new database call it 'elruf.mdb' or whatever you want
make a new table call it 'SeedTray'
add a field call it 'SlotNr'
give it a datatype of longinteger
make it the primary key (and call the index msaccess creates for you 'SlotNr')
give it a validationrule of: >0 And <73
give it a validationtext of: the slot number has to be from 1 to 72 both included
Default Value= nothing(simply remove whatever there is) probably it was 0
required=yes
indexed=yes(no duplicates)
add a field call it 'Seedname'
give it the text datatype
required=no
add a field and call it 'Memo'
so now you have created the database and a table called 'SeedTray'
now to make it easy we are going to fill this tables with SlotNr's from 1 to 72
open the table
type under SlotNr: 1
move cursor down and type: 2
do this 70 times more
(if all is well, from here on you only have to move down cursor
so now you have a database and a table, with for each slot in your seedtray a record
so lets make the vb program
start visual basic6
new..standard exe
drop a data control on the form
properties of the data control:
Connect=Access
Databasename=the path to the database
(just click the ellipses and choice)
RecordsetType=0-Table
RecordSource=SeedTray
drop a label on the form
properties of the label:
DataSource=Data1
DataField=SlotNr
now run the program
click the arrows of the datacontrol
a miracle happens
drop a textbox on the form
properties of the textbox:
Multiline=true
DataSource=Data1
DataField=Memo
drop a textbox on the form
properties of the textbox:
DataSource=Data1
DataField=SeedName
run the program
and play a bit with it
now you can fill the SeedTray already with what you want
now drop an array of command buttons on the form
index=1 to 72
Code:
Private Sub Command1_Click(Index As Integer)
Data1.Recordset.Seek "=", Index
End Sub
Private Sub Form_Activate()
Data1.Recordset.Index = "SlotNr"
End Sub
there you go, in no time a program to do what you want
took me 2 minutes to "write" hihi that program
took me a lot longer to explain to you
hope a genius such as you can understand it
if you had done what i told you in post #12
or anything what the other participants told you
it would have been done long ago already
but i can understand that for a genius such as you that was far to simple
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
@ IkkeEnGij
first: it doesn't matter how many or to what extent i edit my post(s) - it's my right to.
secondly: i don't care who or how many people can see all the editing i have done to any of my posts - i was a mod too.. several times, so i know it can be done - bottom line is i still don't care.
thirdly: who does or does not use my app is none of your concern or anyone else's on here now is it? just sux that everone has access to my idea/program they didn't come up with on their own! that's the only part i hate..
you wanna know how i want my program to work as you said in your last post? read post #13, also look at the program i uploaded.. oh, and since you complained about contacting you in a PM.. mine is open to everyone.. i don't ***** and complain like you when someone contacts me for any reason.. unless they are rude or inappropriate.. which i wasn't! right now, yes i am being defensive because you sir are acting like a forum bully! put yer coding where your mouth is instead of letting a topic drag on since you think you know it all!!! you say it's easy? prove it!
let's end this bs once and for all.. yes, i'm calling you out on your coding skills mister know it all.. hey, you put yourself out there - so show us!
i don't need you to write my program, but i am calling you out to make it work the way i want it to since you think it's so easy! or you gonna keep running your mouth and judging me, my skills and my ideas?
yeah, that's what i thought.. can run his mouth but can't back up what he says..
fourth: you have a big mouth and are very judgmental - (i laugh because guys like you don't say what they do face to face.. i do! i can back myself up in person.. i say to you on here in public view as i would to your face! i don't hide behind a pc and text tough unlike people like you)..
you say you are willing to help "even write my program", which i don't need thank you - i have coded and released several without your help in the past.. but yet you say you can.. then put your coding where your mouth is! so yes, i'm calling you out as i would face to face.
oh, and since you're not gonna help.. stay out of my topics from now on!
now we wait for his tantrum and still no proof it's as easy he says it is and without any actual help...
post over! sorry i even started the post.. helpers my a$$ - with the exception of nightwalker83 who actually did attempt. - OFFICIAL REQUEST that someone lock or delete this topic.. pointless at this point.
@nightwalker83
i won't PM you anymore since you complained about it - but i thank you for attempting to try to help..tho it was buggy - i still thank you for trying unlike unmentioned names... but you did try, i can respect that.
since the genius is so rude and impolite to delete entire postings just quoted it
-
Re: Save to database.. Please help
again, as mentioned in post #42.. i don't care about editing/deleting my posts..
funny how you typed all that instead of actually helping.. meaning opening my app and working on it and then explaining.. that was too hard for you i guess.. yer the type to assume by looking at pictures will give you the full insight on how the program should be coded or how i should do things.. you really wanna help someone out? open their project and look at it and then go from there..
again, i'm done with you and this post!
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
funny how you typed all that instead of actually helping.. meaning opening my app and working on it and then explaining.. that was too hard for you i guess..
This is the type of stuff that SHOULD be discussed via private message!
I understand you are now trying to figure out how the system where you click a button on the main form know how to refer to a particular item once that item is in the system? That is going by what you said in post #34, I will try to figure this out.
-
Re: Save to database.. Please help
Hard to believe this thread is still going, 8 days, 46 posts for something that should have been possible in less than one hour given the code in the first post and the question at hand as to how to save 5 fields to a database.
There are several ways to do it, all of which are easy and with a little effort could be done in less than an hour with no previous experience in DB access. I haven't read all the posts, perhaps the question has changed but it really seems more like the OP wants someone to do it for him rather than spend an hour or two figuring out how to do it.
From the OP
Code:
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
All that needs to be done is change the values in "s to the actual field names in the database in question, remove a few of those lines since you only wanted to save 5 fields and change the textx references to match whatever it is you want to save. Of course this should have been obvious just by looking at the code, Surely should not take a week to figure out.
Other than that all that is needed is to have the reference to DAO added to the project and make sure the line that opens the DB and table are pointed to the correct DB and table.
Of course it would be better to use ADO but that also is very simple to do such a simple thing in.
-
Re: Save to database.. Please help
Version 3
Fixed up the association between the buttons on the main for an the records.
Added the code to reset the database.
Fixed the saving to and loading form the database.
-
Re: Save to database.. Please help
after creating a record.. still calls the first entry made when looking at the entries..
i created a couple.. but when i go to click on them, still brings up the info on the first one made in other words instead of their own records. we can get rid of the quantities in the database, add form and entry form as mentioned - it's made for 1 seed per button.. i was planning differently, but IkkeEnGij made a big stink about the app - so i decided to go back to it's original intent.. 1 seed per button
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
after creating a record.. still calls the first entry made when looking at the entries..
i created a couple.. but when i go to click on them, still brings up the info on the first one made in other words instead of their own records. we can get rid of the quantities in the database, add form and entry form as mentioned - it's made for 1 seed per button.. i was planning differently, but IkkeEnGij made a big stink about the app - so i decided to go back to it's original intent.. 1 seed per button
Can't believe the attitude and the tone you're using here - how you command
others around (who apparently didn't have enough of your antics yet).
When one reads stuff like:
"We can get rid of the quantities..."
"...i was planning differently..."
"...i decided to go back to it's original intent..."
...it indeed sounds like you really believe, that you're actually *doing-something*.
But you are Not! (...aside from "bossing others around"...)
WTH - this forum is thought for *developers* (asking for help from other developers) -
not for "guys with a manager-attitude", who don't even try to learn the basics
of programming, to begin to start implementing some simple things on their own.
There's sites like "Rent a Coder" where you might get your software-product-idea
of a "One seed per Tray-Slot, one Tray only"-DB-App realized finally.
Olaf
-
Re: Save to database.. Please help
@ Schmidt
i'm not ordering anyone around.. you have some nerve to even think or say that! i just mentioning it to nightwalker83 - i can easily remove it myself, was trying to make it easier when calling back the entry info. and yes, i did do something, i designed the whole app! nightwalker83 is just being nice and helpful trying to get it to work with the DB, but other than that i am doing the rest thank you very much!
-
Re: Save to database.. Please help
Have a look at attachment posted by MarkT in post#36 here.
-
Re: Save to database.. Please help
nice! so far it looks like it works the way it was intended.. thank you and thank you to MarkT.. i just have 1 question tho, just to clear things.. why is there an ID and TrayPosition in the DB? i'm just trying to make sense of it.. because wouldn't they both be the same?
like id says 3 but tray position says 32.. wouldn't it be 32 for both since that's the slot i clicked on when adding a seed? just curious
i get it was the 3rd entry made... but what relevance does that make when only trayposition is what matters - is it to help collect the data for that specific seed?
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
nice! so far it looks like it works the way it was intended.. thank you and thank you to MarkT.. i just have 1 question tho, just to clear things.. why is there an ID and TrayPosition in the DB? i'm just trying to make sense of it.. because wouldn't they both be the same?
No, the ID would be the button ID whereas TrayPosition would hold the Record ID. The Record ID is going to be 1 less than the button index because the record set start at -1 where as the button index start at 0.
-
Re: Save to database.. Please help
i did notice one thing tho.. if i select anything other than "Hot" or "Mild" - it won't save it to the db as such.. saves as mild :confused:
i also tweaked the app, but i did not touch the coding that saves to the db.. the error already pre-existed
working seed tray
-
Re: Save to database.. Please help
In the addRecord sub you have to check which option button is selected and then save the value.
Code:
Private Sub addRecord()
Dim cn As ADODB.Connection
Dim sql As String
Dim i As Integer
For i = 0 To Option1.UBound
If Option1(i).Value Then
Exit For
End If
Next i
sql = "Insert Into Table1(TrayPosition,Name,[Date],Spice,[Plant Type]) " & _
"Values([TRAYPOSITION],'[NAME]','[DATE]','[SPICE]','[PLANTTYPE]')"
sql = Replace(sql, "[TRAYPOSITION]", intBtnIndex)
sql = Replace(sql, "[NAME]", Text1.Text) 'Saves the Seed name to the database
sql = Replace(sql, "[DATE]", Text3.Text) 'The date the seed was planted
sql = Replace(sql, "[SPICE]", Option1(i).Caption) 'The how hot the seed is
sql = Replace(sql, "[PLANTTYPE]", Combo1.Text) 'The type of seed (example: vegtable)
On Error GoTo HandleSaveErrors
Set cn = GetConnection
cn.Execute sql
Set cn = Nothing
blnAdded = True
Exit Sub
HandleSaveErrors:
strMessage = "Record could not be saved. " & vbCrLf & Err.Description
MsgBox strMessage, vbExclamation, "Database Error"
End Sub
In reality, it would be much better to save the option button index instead of the caption. If you save the index you wouldn't need a Case statement to select the saved option button when you call FillFields in your Entry form. All you would need to do is
Code:
Option2(rs!Spice).Value = True
If you run with this approach you need to change the Spice column in the table from Text datatype to Number and adjust the insert query so Spice is not wrapped in single quotes.
-
Re: Save to database.. Please help
Quote:
Originally Posted by
Nightwalker83
No, the ID would be the button ID whereas TrayPosition would hold the Record ID. The Record ID is going to be 1 less than the button index because the record set start at -1 where as the button index start at 0.
You have that backwards.
Id = the id of the record
TrayPosition = the index of the button that stores the details
In databases, Ids (primary key) should be unique auto generated values. The application should have nothing to do with the management of them. Ids become important when doing CRUD operations.
In simplest terms, the changes I made were to save the id (record id) in the tag property of the button when loading the tray. This way you always know which record to work on. The I added TrayPosition so you know where to place the seed in the tray when you loading the data.
-
Re: Save to database.. Please help
Quote:
In reality, it would be much better to save the option button index instead of the caption. If you save the index you wouldn't need a Case statement to select the saved option button when you call FillFields in your Entry form. All you would need to do is
Code:
Code:
Option2(rs!Spice).Value = True
If you run with this approach you need to change the Spice column in the table from Text datatype to Number and adjust the insert query so Spice is not wrapped in single quotes.
i did exactly as you said, however i get the following highlighted in yellow after i run the app and go to "entry" form
Code:
Option2(rs!Spice).Value = True
-
Re: Save to database.. Please help
Quote:
Originally Posted by
elRuffsta
i did exactly as you said, however i get the following highlighted in yellow after i run the app and go to "entry" form
Code:
Option2(rs!Spice).Value = True
By exactly does that mean you updated the database Spice Column datatype also?
Quote:
Originally Posted by
MarkT
If you run with this approach you need to change the Spice column in the table from Text datatype to Number and adjust the insert query so Spice is not wrapped in single quotes.
When you get an error I helps a lot if you say what the error is instead of just I got an error on this line. Do you ever take your car in for repairs and just tell them it isn't working correctly? It's all in the details.
-
Re: Save to database.. Please help
Quote:
Originally Posted by
MarkT
In databases, Ids (primary key) should be unique auto generated values
MarkT,
would it be ok with you, if i open a new topic in the database section, asking for comments on that statement ?
and would it be ok, if i quote you there ?