Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Jun 2004
    Posts
    43

    Unanswered: newbie here... help pls i need this ASAP.tnx

    hi,
    i need to know how query can be used in a form, because my teacher said that i should use sql in a query. can you give me an example on how to use query in a form?

    2. can i use insert into, delete from, update in event of a command button? can you give an example?

    3. i have 2 textbox txtbalance is from an account table and one textbox is for user input. what i want to know is the code to use on the command button so i can subtract the value of the 2 textbox.

    4. i want to learn how to create the login with password before a user can access. can you help me?

    thank you very much in advance

    God Bless!!!

  2. #2
    Join Date
    Mar 2004
    Location
    UK
    Posts
    30
    ok...

    1-In the form properties window under the data tab click the elipsis button (a small square with 3 dots ... in it) next to the RecordSource row (should be at the top of the data page). Then use the query builder to add a SQL statement record source to your form.

    2-Yes you can. On the click event of the button use

    DoCmd.RunSQL "sql statement"

    Example:
    Code:
    DoCmd.RunSQL "DELETE tblData.* FROM tblData WHERE tblData.Date=#01/01/04#;"
    3-I have used 3 text boxes in this example.

    txtBalance
    txtUserInput
    txtTotal

    In the button click event use the following code

    txtTotal = txtBalance - txtUserInput

    This should subtract the one from the other. The text box txtTotal could be replaced by any form of providing the answer such as a message box

    4-Which version of Access are you using??? I will try to dig out my tutorial for the user level security. i have ones for 97 and XP.

    Hope the above helps

  3. #3
    Join Date
    Jun 2004
    Posts
    43
    i'm using access from office2003 sir.

    3. in no. 3 of my question after subtracting it should update the data in the table.
    balance=balance-textbox.value
    is this possible? how can i update after subtracting..

    thank you for the help sir...

  4. #4
    Join Date
    Jun 2004
    Posts
    43
    in line with my question1 how can i use a select statement on the form what is the effect because i used the join table and i only see the attributes that i join in a box and when i drag it it create a text box... what other use can query do in a form?


    tnx

  5. #5
    Join Date
    Mar 2004
    Location
    UK
    Posts
    30
    I am afraid that I dont have a tut for access 2003 but assuming it will be similar to 2002 then i suggest you create a copy of the database and have a go with the built in wizard. Its unders tools | security | user level wizard

    As for the part 3 you could try doing txtBalance = txtBalance - txtUserInput
    If the fields are linked to the table direct then this will automatically change your table.

  6. #6
    Join Date
    Jun 2004
    Posts
    43
    tnx sir no.3 works.

    how can i make it invalid if it turns negative
    example:
    when a customer withdraws money and balance is not enough
    what should i add in my code?

  7. #7
    Join Date
    Jun 2004
    Posts
    43
    sir can you give me an example of the DoCmd.RunSQL usind insert and using update

    my attribute are:
    customerID
    accountNo
    balance

    2. what if the user leave a textbox blank will it add or update?

  8. #8
    Join Date
    Jun 2004
    Posts
    43
    sorry if i have many question... i have only little knowledge in access i know VB and sql so i can only understand some of access...

    pls. help i have to sleep now i'll be back tommorow pls post the answers thankyou!

  9. #9
    Join Date
    Jun 2004
    Posts
    43
    another question:

    can i use a query in a command button's event?

    example
    command1="query name"

    what is the format of the code if i can use... tnx

  10. #10
    Join Date
    Mar 2004
    Location
    UK
    Posts
    30
    Quote Originally Posted by oeuf85
    tnx sir no.3 works.

    how can i make it invalid if it turns negative
    example:
    when a customer withdraws money and balance is not enough
    what should i add in my code?
    you could add an If statement to your code.

    something like the below

    Code:
    If txtBalance < txtUserInput Then
         MsgBox "This transaction would make you overdrawn.  Unable to complete"
         txtUserInput = ""
         Exit Sub
    Else
         txtBalance = txtBalance - txtUserInput
    End If

  11. #11
    Join Date
    Mar 2004
    Location
    UK
    Posts
    30
    Quote Originally Posted by oeuf85
    another question:

    can i use a query in a command button's event?

    example
    command1="query name"

    what is the format of the code if i can use... tnx
    Yes you can. on the buttons click event use

    DoCmd.OpenQuery "query name"

    If the query is a Select query it will open to view otherwise it will run the action query ie Delete, Update, Append etc

  12. #12
    Join Date
    Mar 2004
    Location
    UK
    Posts
    30
    Quote Originally Posted by oeuf85
    in line with my question1 how can i use a select statement on the form what is the effect because i used the join table and i only see the attributes that i join in a box and when i drag it it create a text box... what other use can query do in a form?


    tnx

    not quite sure what you mean here. linking forms to queries is usually when the data you want on the form comes from more than one table. as a record source you would only use the select statement. other query types cant be linked to a forms data source.

  13. #13
    Join Date
    Jun 2004
    Posts
    43
    hi,

    i'm making a bank system do you know how to manipulate the date for computation to give the customers their monthly interest

    tnx!

  14. #14
    Join Date
    Jun 2004
    Posts
    43
    how can i get the system date to be used for the subtraction?

  15. #15
    Join Date
    Jun 2004
    Posts
    43
    Quote Originally Posted by kadanis
    Yes you can. on the buttons click event use

    DoCmd.OpenQuery "query name"

    If the query is a Select query it will open to view otherwise it will run the action query ie Delete, Update, Append etc
    if i use select where will be the output if i click the button. is it possible to have the output on the form? or it will open a new window?

    can you give me example?

    tnx

Posting Permissions

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