Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Apr 2011
    Posts
    12

    Unanswered: Make counter in forum copy to table

    Hi,
    I have table with one filed named number.
    and I made form with two field,start and end type number .
    i will put range from 232 to 900 into start and end,i want to copy all number between 232 to 900 inside table field number after press botton on that forms
    see attached file database
    Thanks
    Salih
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You can use this:
    Code:
    Private Sub Command_InsertNumbers_Click()
    '
    ' TableOne is the name of the table.
    ' Command_InsertNumbers is the name of the command button.
    ' Text_Start and Text_End are the names of the 2 text boxes.
    '
        Const c_strSQL As String = "INSERT INTO TableOne ( [Number] ) VALUES ( {Number} );"
        
        Dim dbs As DAO.Database
        Dim i As Integer
        
        If IsNumeric(Me.Text_Start.Value) And IsNumeric(Me.Text_End.Value) And (Me.Text_Start.Value < Me.Text_End.Value) Then
            Set dbs = CurrentDb
            For i = Me.Text_Start.Value To Me.Text_End.Value
                dbs.Execute Replace(c_strSQL, "{Number}", CStr(i))
            Next i
            Set dbs = Nothing
        End If
        
    End Sub
    Have a nice day!

  3. #3
    Join Date
    Apr 2011
    Posts
    12

    I am send you attached can put code on it

    Hi,
    Plz see attached file my database can put code on it

    thx
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Sorry but I'm not used to dig in databases from unknown origin without a word of explanation. Moreover, I do not see what it would change as far as the question you asked and the response I provided are concerned.
    Have a nice day!

  5. #5
    Join Date
    Apr 2011
    Posts
    12

    reason i send u database

    Dear Friend,
    Many thanks for u,
    I try to put ur code into that database i had some problem,,,
    in put code into place,,,
    therefore i send u database as attached to seed it and iam ready to send via email if u want

    thx

  6. #6
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Simply copy the code into the module of the form where you intend to use it then link it to the Click event of the button you were talking about in your first post.
    Have a nice day!

  7. #7
    Join Date
    Apr 2011
    Posts
    12

    i use office 2007

    hi,
    I am using fooice 2007
    this work with it

    thx

  8. #8
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

  9. #9
    Join Date
    Apr 2011
    Posts
    12

    I copy ur code

    Hi,
    friend i have copy that code ,ur sure it work
    can test it please,i did my best not work

    ur help plz


    thx

  10. #10
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Yes, I'm 100% sure that it works. I tested the code both in Access 2003 and Access 2007 with a local table and with a linked table.

    What kind of problem do you encounter ? What error message (if any) do you receive? Saying that it does not work does not help in identifying the cause of the problem. You can have more information on a possible error by replacing the line:
    Code:
     dbs.Execute Replace(c_strSQL, "{Number}", CStr(i))
    with:
    Code:
    dbs.Execute Replace(c_strSQL, "{Number}", CStr(i)), dbFailOnError
    Please copy the code as it is in your database and paste it here. Also be sure that you correctly associated the procedure with the command button (is the procedure executed when you click on the command button?). Finally check that there is no constraint applied to the table (Not Null, etc.) that would prevent the insertion of new lines only containing something in the [Number] column.
    Have a nice day!

  11. #11
    Join Date
    Apr 2011
    Posts
    12

    See how i copy ur code

    Hi,
    friend in table i have following fields in tableOne

    -Text_Start as number (starting number)
    -Text_end as number(end n umber)

    in form as i have all above filed plus click bottom for function

    after i copy ur function nothing appear

    Private Sub Command_InsertNumbers_Click()
    Const c_strSQL As String = "INSERT INTO TableOne ( [Number] ) VALUES ( {Number} );"

    Dim dbs As DAO.Database
    Dim i As Integer

    If IsNumeric(Me.Text_Start.Value) And IsNumeric(Me.Text_End.Value) And (Me.Text_Start.Value < Me.Text_End.Value) Then
    Set dbs = CurrentDb
    For i = Me.Text_Start.Value To Me.Text_End.Value
    dbs.Execute Replace(c_strSQL, "{Number}", CStr(i)), dbFailOnError
    Next i
    Set dbs = Nothing
    End If
    End Sub
    --------------
    see attached all info form and code too
    Attached Thumbnails Attached Thumbnails code.jpg  

  12. #12
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    What's the name of the command button and is its Click event linked to the code?
    Have a nice day!

  13. #13
    Join Date
    Apr 2011
    Posts
    12

    I change my command into same ur bttom

    Hi,
    I copy ur function and change my command name as its
    in fuction...
    betetr i install team view in my pc and u work on it
    direct if you do mind

    thanks

  14. #14
    Join Date
    Apr 2011
    Posts
    12

    Still wait problem not solve

    Hi,
    I want some help me,after all work my problem still.
    i copy code as per advise not working

    thx

  15. #15
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If you don't acknowledge the requests for information, how do you expect to receive more help?
    What's the name of the command button and is its Click event linked to the code?
    Have a nice day!

Posting Permissions

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