Results 1 to 6 of 6
  1. #1
    rramico is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    2

    Exclamation helping in a database problem

    hey guys..i'm new here and also new in using ms access.pls if you could help me i will be in great debt to you..i want to solve a problem that sounds like this:
    lets say i have 3 shops and same products in all shops and different stock for each product in each shop. i want to create something that will allow me to move a certain quantity of a product from a shop to another.for example:


    i want to move 3 books(the same unique code) from shop 1 to shop 2 and automatically subtract that 3 books from shop 1 and add that 3 books in shop 2.i have designed the form with the options and button. it looks like this: http://postimage.org/image/aam3uvxg/ .so when i click that button it should to those operations(subtract from.. and add to..).i also did the macro that allows me to choose from those options i designed there but i don't know what command to write in that macro.
    how can i do this?
    thanks a lot

  2. #2
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    This should work, I am still a beginner at SQL myself, but the syntax looks correct.

    This should be the onclick() event of the button that you added to your form:

    Code:
    DoCmd.SetWarnings False
    
    DoCmd.RunSQL "INSERT INTO *tableName you are inserting into* (Quantity,  Code) VALUES('" & Me.Quantity & "', '" & Me.Code & "')"
    
    DoCmd.RunSQL "Delete *tableName you are deleting from* (Quantity,Code)  Values ('" & Me.Quantity & "', '" & Me.Code & "')"
    
    DoCmd.SetWarnings True
    And make sure you add the table that you are wanting to insert into, and that is assuming that the name of the fields on your form are Quantity, and Code

  3. #3
    Sudha is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    3

    MS Access Database

    Hi,

    Could someone help me to solve the below problem urgently please......

    I have 2 tables

    1. 1st table contains the Pkey(autonumber)
    2. The same feild is set as Fkey in the 2nd table

    Problem:

    I need to get the autnumber from the parent table to child table.

    Kindly do the needful.

    Thanks & Regards,
    Sudha

  4. #4
    jo15765's Avatar
    jo15765 is offline Expert
    Windows 7 Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    lets say the parent table is called table1 and child table is table2

    open a query pull in table1 and table2

    pull down fkey, and change to an update query

    on the update to line type:
    [table1].[Pkey]

    This is saying to update the field fkey to the value of Pkey in table1

  5. #5
    rramico is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    2
    Quote Originally Posted by jo15765 View Post
    This should work, I am still a beginner at SQL myself, but the syntax looks correct.

    This should be the onclick() event of the button that you added to your form:

    Code:
    DoCmd.SetWarnings False
    
    DoCmd.RunSQL "INSERT INTO *tableName you are inserting into* (Quantity,  Code) VALUES('" & Me.Quantity & "', '" & Me.Code & "')"
    
    DoCmd.RunSQL "Delete *tableName you are deleting from* (Quantity,Code)  Values ('" & Me.Quantity & "', '" & Me.Code & "')"
    
    DoCmd.SetWarnings True
    And make sure you add the table that you are wanting to insert into, and that is assuming that the name of the fields on your form are Quantity, and Code
    thanks for the quick answer. i've managed to solve this in a similar way.
    i've created an sql update query for adding(http://www.sql-tutorial.net/SQL-UPDATE.asp) the quantity and another for subtracting.and in the macro i gave the command open query, and set the onclick event on running that macro. it works just fine.

  6. #6
    Sudha is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    3
    Thank you :-)


    Quote Originally Posted by jo15765 View Post
    lets say the parent table is called table1 and child table is table2

    open a query pull in table1 and table2

    pull down fkey, and change to an update query

    on the update to line type:
    [table1].[Pkey]

    This is saying to update the field fkey to the value of Pkey in table1

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

Similar Threads

  1. Problem with Database
    By colombianaccess in forum Programming
    Replies: 0
    Last Post: 03-09-2011, 08:26 AM
  2. PTW Database Problem
    By Singapore Sam in forum Access
    Replies: 3
    Last Post: 12-05-2010, 02:41 PM
  3. Total noob needs a helping hand?
    By Naz in forum Access
    Replies: 7
    Last Post: 01-28-2010, 08:35 AM
  4. database problem
    By lukifer in forum Access
    Replies: 3
    Last Post: 07-17-2009, 07:39 AM
  5. database problem
    By st3ven_J in forum Access
    Replies: 0
    Last Post: 02-12-2009, 07:27 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