Results 1 to 3 of 3
  1. #1
    CFGOYANES is offline Novice
    Windows 8 Access 2013
    Join Date
    Feb 2014
    Posts
    1

    Angry Create a Stock of documents numbers

    Hello,



    I need to create and assign a stock of documents numbers by office. This numbers should be stored in a "Qry_Store_DocNumber_By_Oficce" Query.

    Exemple:
    Form

    Click image for larger version. 

Name:	FormCreateDocs.png 
Views:	12 
Size:	9.0 KB 
ID:	15311



    Clicking the "assign and Create Stock" button should be created in "Qry_Store_DocNumber_By_Oficce" query, 5 records (11111 19999, 11111 20000, 11111 20001, 11111 20002 and 11111 20003), documents assigned to the office " Office test".

    Click image for larger version. 

Name:	Query.png 
Views:	12 
Size:	8.2 KB 
ID:	15313

    I did the procedure below but is not working.


    Private Sub IncrementaStock_Click()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim vlr As String
    Dim Qtd As Long
    Dim CpOffice As Integer
    Dim CpIdBilhete As Integer
    Dim i As Long

    Set db = CurrentDb()
    Set rs = db.OpenRecordset("Qry_Store_DocNumber_By_Oficce")

    vlr = Me.DocNumber.Value - 1
    Qtd = Me.Amount.Value
    CpIDOffice = Me.IDOffice.Value
    CpIdDoc = Me.IdDoc.Value

    For i = 1 To Me.Amount.Value
    rs.AddNew
    rs("DocNumber") = vlr + i
    rs("Amount") = Qtd - i + i
    rs("IdOffice") = CpOffice
    rs("IdDoc") = CpIdBilhete
    rs.Update

    Next
    MsgBox ("Bilhetes Gerados!!!!")
    rs.Close
    db.Close
    End Sub


    Please Help!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Numbers cannot be 'stored' in query, records must be created in table. Why open recordset from a query, why not just reference table as the source?

    Did you notice misspelling of Office in the query name?

    Why doesn't it work - what happens? Error message, wrong results, nothing?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Based on this
    I need to create and assign a stock of documents numbers by office. This numbers should be stored in a "Qry_Store_DocNumber_By_Oficce" Query.
    .

    I suggest you tell the readers WHAT the business issue is and WHY a query is how it will be stored. Get specifications for the business problem/opportunity before jumping in with "I need".

    Do some research on Database Principles and Database Design.
    Post back if you need specific links.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-13-2013, 05:01 AM
  2. Automatically create numbers
    By W-technologies in forum Database Design
    Replies: 2
    Last Post: 03-26-2013, 06:15 AM
  3. Replies: 6
    Last Post: 04-27-2012, 05:14 PM
  4. Replies: 1
    Last Post: 11-29-2011, 08:43 AM
  5. how do I create custom part numbers?
    By Sinatra Fan in forum Database Design
    Replies: 1
    Last Post: 09-01-2006, 04:09 PM

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