dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: Some help with coding in access with VB

  1. #1
    Join Date
    Oct 2018
    Posts
    6

    Some help with coding in access with VB

    Hi guys,

    If you can help me I will be very grateful. I work in access and coding with VB but I'm not expert . This is code(below text) for my stopwatch and all work ok, but I need now when I click on cmd buton Pause( in my language Pauza) that ID from table evidencija skeniranja be paused and then other ID when click start that time can go normal but when I click to previuos ID that ID need to be stoped(because I click stop on that ID) but that ID just go to counthing. Can somebody can help me to solve this problem? (

    Code:
    Private Sub cmdEnd_Click()
    Dim rs As DAO.Recordset
    Me.TimerInterval = 0
    Set rs = CurrentDb.OpenRecordset("Select * From Evidencija skeniranja")
    rs.AddNew
    rs!StartOfTest = Me.txtSessionStart
    rs!EndOfTest = Now()
    rs!ActualMinutes = Me.txtActualMinutes
    rs!ActualSeconds = Me.txtActualSeconds
    rs.Update
    rs.Close
    Set rs = Nothing
    MsgBox "Data logged.", vbOKOnly, "Logged"
    End Sub
    
    Private Sub cmdPause_Click()
    If Me.cmdPause.Caption = "Pauziraj" Then
       Me.cmdPause.Caption = "Otpauziraj"
    Else
       Me.cmdPause.Caption = "Pauziraj"
    End If
    End Sub
    
    Private Sub cmdStart_Click()
    
    Me.txtActualMinutes = 0
    Me.txtActualSeconds = 0
    Me.txtSessionStart = Now()
    Me.cmdPause.Caption = "Pauziraj"
    Me.TimerInterval = 1000
    End Sub
    
    Private Sub cmdExit_Click()
      DoCmd.Close
    End Sub
    
    Private Sub Form_Timer()
    '
    ' 1st, update the overall time.
    '
    Me.txtTotalSeconds = Me.txtTotalSeconds + 1
    If Me.txtTotalSeconds > 59 Then
       Me.txtTotalMinutes = Me.txtTotalMinutes + 1
       Me.txtTotalSeconds = 0
    End If
    '
    ' If not paused, add to actual time.
    '
    If Me.cmdPause.Caption = "Pauziraj" Then
       Me.txtActualSeconds = Me.txtActualSeconds + 1
       If Me.txtActualSeconds > 59 Then
          Me.txtActualMinutes = Me.txtActualMinutes + 1
          Me.txtActualSeconds = 0
       End If
    End If
    DoEvents
    End Sub
    Best regards,
    Bojan
    Last edited by 2kaud; October 25th, 2018 at 06:07 AM. Reason: Added code tags

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,291

    Re: Some help with coding in access with VB

    I assume you mean that you are using VBA in Access. I don't do any coding in Access or Office VBA so I'm not sure what is and is not supported. I do know VB very well but VBA is a bit different, even a bit different in each different product.

    What is happening now vs what you want to happen?
    When is the user clicking each of those buttons?
    How many of these are you trying to track at once?
    Last edited by DataMiser; October 25th, 2018 at 06:06 PM.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Oct 2018
    Posts
    6

    Re: Some help with coding in access with VB

    Hi DataMiser,

    Yes your totally right and I using VBA in Access and thank you for anyway for help.

    What is happening now vs what you want to happen?

    Now happening that when one user work in program and when he/she put some parameters in that program and then click on button cmdStart his/her stopwatch counthing when click on button cmdPause than stopwatch stop and also he/she can repause on same button (this is all work perfect for one user) and then enter. All that is going in table with his/her ID( where ID is autonumber). Then when other or second user need to work and put all paramaters in table and when he/she click on button start stopwatch going to counthing and when he/she click on button pause/repause than stopwatch stop. Problem is now: When user 1 (ID) click on cmdpause and user 2 (other ID) work in application user 1(ID) will also pause his/her work and if user 2 click on repause he/she will also start work of user 1(previous ID)

    How many of these are you trying to track at once?
    Max 50 users.

    Tnank you DM for helping me

  4. #4
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,291

    Re: Some help with coding in access with VB

    Are these different users on different PCs sharing the database or are you talking about users on the same pc?

    I do not see anything in the code that identifies a user.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Oct 2018
    Posts
    6

    Re: Some help with coding in access with VB

    That is one PC, and then when user1 put parameters and then click enter then all parameters what he introduced go into table in Access. When other user seat on same PC(program still working user1), parameters is now empty and user now can work on his project. But problem is that when for example user 1 stop his work because he must go on lunch he also stop time for all users. If you want i will send you access.db on email that you can see from firsthand what is my problem. And if you can solve that i will be very grateful if you can't solve that i will also be grateful because you offered yourself to help me for problem that i have.boj.djurovic@gmail.com this is my email

    I do not see anything in the code that identifies a user

  6. #6
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,291

    Re: Some help with coding in access with VB

    It appears that the code you have posted does not have anything in it to determine anything related to who is using it. It looks like all it does is updates a couple of display elements while the timer is running and then writes the content of those to the db when the stop button is pressed. If you want to handle multiple running totals then you need separate variables for each of them and you need to be able to identify which user should be associated which each of those so that your code can update the proper var(s) as needed and then write the proper data when triggered. I also notice that your close does nto call the stop code so it would appear that if they close the form without hitting stop that nothing would be written.
    Always use [code][/code] tags when posting code.

  7. #7
    Join Date
    Oct 2018
    Posts
    6

    Re: Some help with coding in access with VB

    Hi DataMiser,

    This is programName:  picture1.jpg
Views: 26
Size:  19.1 KBName:  Table.jpg
Views: 26
Size:  12.9 KB. Now when everything is entered user press the button "Unesi" and all that going to the table. Now again she/he can work normaly on other his/her project. And the problem is just now when that worker press button "pocetak rada(translate start work)" (he must press that button because his/her time need to counting) and if he/she press the button "Previous record" also time for that user continues to counthing. If you can help me just when user press the "previous button" that time not go to counthing if he/she does not want that and if want he/she will press button "Otpauziraj or translated Pause/Repause"

  8. #8
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,291

    Re: Some help with coding in access with VB

    Like I said you need to treat them separately. This would require you to know which user is using the system at any given time and update the tie for that user. You seem to be just adding a new record to the db when stop is clicked and that record does not appear to be linked to any user.
    Always use [code][/code] tags when posting code.

  9. #9
    Join Date
    Oct 2018
    Posts
    6

    Re: Some help with coding in access with VB

    DM can you help me with coding? Hm I think that all need to be linked just with ID. Because time going to the table where ID is primary. And all what need to be done is when that user or ID use the program to the fill information when he/she start program when he/she click on stop that he/she doesn't stop the project of the other ID when she/he click on the previuos buton(to work normaly on his/her project). I will be very grateful if you can help me to code it.

  10. #10
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,291

    Re: Some help with coding in access with VB

    All you are adding is the time, there is nothing there to identify the user. In order to link to the user then you must have the userid as part of the record and you do not seem to have that in there. You are simply adding a new record and I assume your id in that table is auto number so it basically means nothing in terms of which user is using the system.

    What is the purpose for this program? Are you wanting to track how much time each user spends on each project or how much time they spend of each day or what?
    It would seem that the first thing you need to do is modify your table structure to accommodate the required fields to meet your goals and then add some variables to your program to handle those values. Stuff like UserID, possibly projectID and so on.
    Always use [code][/code] tags when posting code.

  11. #11
    Join Date
    Oct 2018
    Posts
    6

    Re: Some help with coding in access with VB

    DM,

    Exactly that. I want to track how much time each user spends on each project. Yes my ID in that table is auto number. This is all perfect work when users use program on their own computer. But i need options that they can use program on just one PC and you told me that now i need to put some new fields userID for example. I send you also 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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)