dcsimg
Results 1 to 24 of 24

Thread: Question about Access database Connected with VB

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    21

    Lightbulb Question about Access database Connected with VB

    Hi ,
    am kind of in conflict here
    I created a database using access

    table name is appraisal table
    three columns

    Research Paper , Conference , Others

    Research Paper = 10 Points
    Conference = 5 Points
    Others = 3 Points

    Anyway what I want to do is the three columns type is checkbox

    create data grid view in visual basic and load appraisal table

    when user run the program and checkbox all of them it should show 18 points in a label , or textbox , or anywhere ;P

    how can I do that ?

  2. #2
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Question about Access database Connected with VB

    Your description leaves a lot to imagination. Are those points different for each record? when user runs the program which record will be displayed?
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    21

    Re: Question about Access database Connected with VB

    yeah sorry due to my bad English lead to poor explantation

    each of those records have a value I don't know if that is possible in access to be done , I know you can create records and insert values in access but I don't know if I can give those records value and make them checkbox style in the table

    User : run the program , see three checkboxes , if he tick all of them , 18 Total Points should be displayed on a label , textbox , or any item can be used as display

    is that clear ?

  4. #4
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Question about Access database Connected with VB

    Almost. WHen you say 18, is that always? Does it depend on the record selected by the user? It could help if you describe what the points mean. What is the purpose of your application? Is it a school project?
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,518

    Re: Question about Access database Connected with VB

    first, you need your database set up correctly:

    Name:  _4.png
Views: 300
Size:  6.5 KB

    Name:  _3.png
Views: 401
Size:  7.1 KB

    then you can use this code:

    Code:
    Imports System.Data.OleDb
    
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Paul\Documents\appraisal.accdb;Persist Security Info=False;")
            Dim da As New OleDbDataAdapter("SELECT * FROM [appraisal]", con)
            Dim dt As New DataTable
            da.Fill(dt)
            dt.Columns.Add("value")
            dt.Columns("value").Expression = "IIf(Research_Paper,10,0)+IIf(Conference,5,0)+IIf(Others,3,0)"
            DataGridView1.DataSource = dt
            DataGridView1.Columns(3).Visible = False
            Label1.DataBindings.Add("Text", dt, "value")
        End Sub
    
    End Class
    which will set up your dgv + label databindings how you wanted them:

    Name:  _2.png
Views: 309
Size:  23.5 KB

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    21

    Re: Question about Access database Connected with VB

    yes it is school project lool ;p

    yeah it is should always be 18 , yes it depend on the user if he select one record or all or record , points is just a weight for each record

    for example I have a database of fruits table that contain ( apple , mango , orange) and
    their prices is

    apple = 5$ ,

    mango 10$ ,

    orange $$


    after creating a form in visual basic , loading fruits table into data grid view I will be able to view the records right apple, mango, orange
    their type is checkbox , after I check all of them it should give me the total price , I should put it somewhere in label or textbox or if it is possible I can save it into another database but that Is difficult I just want to learn the first part only ;S

  7. #7
    Banned
    Join Date
    Apr 2014
    Location
    Ireland
    Posts
    3

    Re: Question about Access database Connected with VB

    I HAVE A PROBLEM!! In Visual Basic, I need to split a csv file into an array and then find max and min values for parts of that array. I am quite stuck at the moment and really need assistance.

    Thanks.

  8. #8
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Question about Access database Connected with VB

    Quote Originally Posted by DylanM View Post
    I HAVE A PROBLEM!! In Visual Basic, I need to split a csv file into an array and then find max and min values for parts of that array. I am quite stuck at the moment and really need assistance.

    Thanks.
    Dylan, first: welcome to the forums. But please start a new thread if you have a question instead of hijacking someone else's. Specially if your issue is so different from the OP's.
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    21

    Re: Question about Access database Connected with VB

    Hi Mr Paul ,
    I checked and done the steps but I think there is something wrong I did , check my screenshots

    my table in access



    the code I put and put my database table source



    is my source is wrong , ?

    because I have two database with same name one inside folder after the VB copy it when I use data source connection

  10. #10
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Question about Access database Connected with VB

    jack, your questions are confusing me more that before.

    How can you say it is always 18 if then you say apple=5, mango=10? where does that fit in?
    how can the fields be checkbox type if they have numbers as values?
    Do you have a table with columns named apple, mango and orange or are these values in different records?
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  11. #11
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Question about Access database Connected with VB

    To correct those errors put this line before the class declaration:

    Code:
    Imports System.Data.OleDb
    The rest of the code is confusing, what are you trying to do?
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    21

    Re: Question about Access database Connected with VB

    Mr Kaliman , apple and mongo what just an example of the previous one ;o

    appraisal table ( Research Paper = 10 Points , Conference = 5 Points , Others = 3 Points )

    I don't know how can numbers or values assign to the records or columns but Mr Paul did it and am trying to do it as well ,

    forget about fruits table , lets go again for appraisal

    Column 1: Research Paper , Column 2: Conference , Column 3:Others

    Their Values Should Be: 10 , 5 , 3


    It is a table with 3 columns , and yes those values should be assigned to their columns !
    I don't know actually how does it fit but am trying mr paul work as that what I want to do

    but currently having something wrong and am trying to get it maybe my source wrong or something else

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    21

    Re: Question about Access database Connected with VB

    yes I put this line now , again something else showed up !


  14. #14

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    21

    Re: Question about Access database Connected with VB



    Something wrong Mr.Paul and Kaliman , what do you think ? shall I try it from the beginning ?

  15. #15
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,518

    Re: Question about Access database Connected with VB

    You need to close Access when you run your project

  16. #16
    PowerPoster kaliman79912's Avatar
    Join Date
    Jan 2009
    Location
    Ciudad Juarez, Chihuahua. Mexico
    Posts
    2,593

    Re: Question about Access database Connected with VB

    Do you have the Access Database open?
    More important than the will to succeed, is the will to prepare for success.

    Please rate the posts, your comments are the fuel to keep helping people

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    21

    Re: Question about Access database Connected with VB

    Well I try it again , new folder System , new database appraisal, new visual basic application Faculty System



    There is still a message , when I run the application ms access is closed

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    21

    Re: Question about Access database Connected with VB

    after removing this line of code

    DataGridView1.Columns(3).Visible = False

    the program work but not functional or accurate , I had to click up , down then start to count and even not correct !


  19. #19

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    21

    Re: Question about Access database Connected with VB

    Thanks to Mr Paul & Kaliman for the help , what I wanted to do didn't work

    I will try to plan more and see another way , I might post another topic tomorrow about same issue but in different way

    Hope there will be someone to help same as today

    Regards,
    Jack

  20. #20
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,518

    Re: Question about Access database Connected with VB

    here's a working example: appraisal DB.zip

  21. #21

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    21

    Re: Question about Access database Connected with VB

    I try to download the attachment it give me

    attachment.php (23.6 KB)

    after downloading it and change format to zip and open it , the file is corrupted

  22. #22
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,240

    Re: Question about Access database Connected with VB

    It is working opening properly for me (in Firefox and IE), is it working for you now? (it may have been a temporary glitch)

  23. #23
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,518

    Re: Question about Access database Connected with VB

    works ok for me too

  24. #24
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Question about Access database Connected with VB

    Works fine from Chrome for me as well.
    Joacim Andersson
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

    MVP

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width