Results 1 to 4 of 4
  1. #1
    sandlucky is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2011
    Posts
    35

    Question Java UI for Access Database : Select Checkbox items and add them to a Database table

    Hi all my proble was removed b'cus it is related to Java. and I got it solved it by posting it to a Java forum. pls do not read this post.



    Thank you very much for all who read and reply. Sorry for difficulty you all face to give a reply to this post.

    I'm using Netbeans 7 to develop a programme to Insert data into a MS Access database.
    Last edited by sandlucky; 05-15-2011 at 10:58 PM. Reason: Problem solved by my own

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    honey, there is no one here that will help you with that, me thinks. post that stuff in a java forum. you're in the wrong place, my dear.

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    First off, I want to make it very clear that I *do not* know how to program in Java. It is a language I would like to learn, along with the C's (C, C++,C#), Python & Perl.

    But I have noticed a couple of things.

    Main table have 2 fields (VID and Name) - VID is the primary key
    "Name" is a reserved word in Access and shouldn't be used for object names (as in field names).


    You have these 3 colors:
    jCheckBox1.setText("Red");
    jCheckBox2.setText("Pink");
    jCheckBox3.setText("Orange");

    And lets set the value of
    VID = 52
    Name = "Test"

    Here is a portion of your code:
    (Comments in line)

    Code:
    private void 
    jButton1ActionPerformed(java.awt.event.ActionEvent evt) { 
    // TODO add your handling code here:
    int VID=Integer.parseInt(jTextField1.getText());
    //variable VID value is now 52
    String Name=jTextField2.getText();
    //variable Name value is now "Test"
    String Color = null;
    if (jCheckBox1.isSelected()){
    Color=String.valueOf(jCheckBox1.getText());
    // variable COLOR value is now "RED"
    }
    if (jCheckBox2.isSelected()){
    Color=String.valueOf(jCheckBox2.getText());
    // variable COLOR value is now "Pink"
    }
    if (jCheckBox3.isSelected()){
    Color=String.valueOf(jCheckBox3.getText());
    // variable COLOR value is now "Orange"
    }
    Keytest d=new Keytest();
    d.openDb();
    //
    // at this point VID = 52, Name = "Test" and Color = "Orange"
    // as long as three colors are selected, 
    // Color will always equal "Orange"
    //
    d.insert1(VID,Name);
    d.insert2(VID,Color);
    d.closeDb();
    }
    You could use 3 variables for the color: Color1, Color2, Color3
    then use

    Code:
    if (jCheckBox1.isSelected()){
    Color1 =String.valueOf(jCheckBox1.getText());
    // variable COLOR value is now "RED"
    }
    if (jCheckBox2.isSelected()){
    Color2 =String.valueOf(jCheckBox2.getText());
    // variable COLOR value is now "Pink"
    }
    if (jCheckBox3.isSelected()){
    Color3=String.valueOf(jCheckBox3.getText());
    // variable COLOR value is now "Orange"
    }
    
    
    d.openDb();
    d.insert1(VID,Name);
    if (jCheckBox1.isSelected()){
    d.insert2(VID,Color1);
    }
    if (jCheckBox2.isSelected()){
    d.insert2(VID,Color2);
    }
    if (jCheckBox3.isSelected()){
    d.insert2(VID,Color3);
    }
    d.closeDb();
    or some kind of looping ..... wish I knew Java

  4. #4
    sandlucky is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2011
    Posts
    35
    @ssanfu, Thanxalot for being so kind.
    Glad to say that I solved the problem by posting it in a Java forum.
    Thank you 100 times for reading my problem and trying to help me.
    Really appreciate your help. TC, God Bless!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Select multiple items from list box
    By sharmaprashant22 in forum Queries
    Replies: 2
    Last Post: 05-05-2011, 12:18 PM
  2. can a access database table be read-only?
    By princess-1 in forum Access
    Replies: 5
    Last Post: 10-24-2010, 07:52 PM
  3. Migration from Access 2003 database to Access 2007 database.
    By cyclus2 in forum Import/Export Data
    Replies: 1
    Last Post: 09-10-2010, 11:43 AM
  4. Replies: 4
    Last Post: 08-12-2010, 08:38 AM
  5. Replies: 0
    Last Post: 08-05-2010, 08:45 AM

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
  •  
Other Forums: Microsoft Office Forums