Prefix + AutoNumber as Item Code

@joannnaellamay

Post 131...
If HR needs a formal database that can (and should) be done separately. Now, this does go against what I have been telling you to keep everything in the same place. However, this is the exception to the rule because of personal information that NO ONE should have access to except HR. We shouldn't even link to it and truth be told, I would not use Access for this unless it can be put on a *locked down* machine.

Post 132...
Tell me what you want the Message Box to say and do and I will give you a few options from which you can pick which one best suits you AND you can use a *Template* for your other Command Buttons.
 
@joannnaellamay

Post 131...
If HR needs a formal database that can (and should) be done separately. Now, this does go against what I have been telling you to keep everything in the same place. However, this is the exception to the rule because of personal information that NO ONE should have access to except HR. We shouldn't even link to it and truth be told, I would not use Access for this unless it can be put on a *locked down* machine.

Post 132...
Tell me what you want the Message Box to say and do and I will give you a few options from which you can pick which one best suits you AND you can use a *Template* for your other Command Buttons.

Post 131...
Okay, let's close the issue. HAHAHA.

Post 132...
Actually, I did it! With Marcos. I used If MsgBox("Is this really what you want to do?",4)=7. But I still don't know how to link the buttons to the actual actions. Anyway, if you have any other ways, please share! :D

Something like:

"Are you sure you want to add a new record?"
"Save record?"

Just statements that asks the user to confirm the action.
 
Oh, I also tried to make a message box form. So I just linked the command button to the form. Then assigned actions for the buttons on the message box. For me this method is a lot easier to manage. I got that trick from the templates.
 
I have not forgotten you... have not been feeling well. Came on yesterday for a bit then went to bed. I will get to this today!
 
Put this in the Event Procedure of the Command Button...

Code:
Private Sub cmdAddNew_Click()
On Error GoTo SmartFormError
 
     Dim intResp As Integer
 
     intResp = MsgBox("Are you sure you want to add a new record?", vbYesNo + vbQuestion, "Save Record?")
 
  If intResp = vbYes Then
    DoCmd.RunCommand acCmdRecordsGoToNew
  Else
    DoCmd.CancelEvent
  End If
 
 Exit_SmartFormError:
    Exit Sub
SmartFormError:
    If Err = 2046 Or Err = 2501 Then
        Resume Next
    Else
        MsgBox Err.Description
        Resume Exit_SmartFormError
    End If
End Sub
 
Okay, I want to digest the code you sent me...

Code:
Private Sub cmdAddNew_Click()
On Error GoTo SmartFormError[QUOTE]

What is On Error and SmartFormError?
 
[QUOTE]Dim intResp As Integer[QUOTE]

Why integer?
 
 [QUOTE]If intResp = vbYes Then
DoCmd.RunCommand acCmdRecordsGoToNew[QUOTE]

I don't really want to go to a new record. I just want the button to serve as a confirmation or something. What do you think is the better action for this?


[QUOTE]Exit_SmartFormError:
    Exit Sub
SmartFormError:
    If Err = 2046 Or Err = 2501 Then
        Resume Next
    Else
        MsgBox Err.Description
        Resume Exit_SmartFormError
    End If
End Sub

Okay this last part was too confusing to digest. HAHA. :banghead:
 
I'm not sure how you want me to answer that. Perhaps if you Google Error 2046 and 2501 and you see what they are it will help you understand what I am preventing with that part.
 
I can't understand why you set intResp and an integer. But anyway, I'll try to research more about it.
 
Oh, that part... because vbYes is actually -1 or 1 and vbNo is actually 0, at least, to Access.
 
Put this in the Event Procedure of the Command Button...

Code:
Private Sub cmdAddNew_Click()
On Error GoTo SmartFormError
 
     Dim intResp As Integer
 
     intResp = MsgBox("Are you sure you want to add a new record?", vbYesNo + vbQuestion, "Save Record?")
 
  If intResp = vbYes Then
    DoCmd.RunCommand acCmdRecordsGoToNew
  Else
    DoCmd.CancelEvent
  End If
 
 Exit_SmartFormError:
    Exit Sub
SmartFormError:
    If Err = 2046 Or Err = 2501 Then
        Resume Next
    Else
        MsgBox Err.Description
        Resume Exit_SmartFormError
    End If
End Sub

:( I'm sorry. I really cannot understand the structure of the code. I only understood:

Code:
Dim intResp As Integer
 
     intResp = MsgBox("Are you sure you want to add a new record?", vbYesNo + vbQuestion, "Save Record?")
 
  If intResp = vbYes Then
    DoCmd.RunCommand acCmdRecordsGoToNew
  Else
    DoCmd.CancelEvent
  End If

I wasn't able to understand SmartFormError and the structure of the code. I have researched about the basics. But I don't know why I still don't get it. I hope I'm not asking for too much, but could you please explain the code bit by bit? Or by group or something? :banghead:
 
I could already use the code, it works wonderfully. But I don't want to keep using it without understanding it fully. :(
 
View attachment X v4.2.accdb

Okay, here's what I have so far. I've followed your advise with the codes. I tried to study the On Error ones and understood how it works. ;) I just hope I used them correctly.

As for the other command buttons, I just used Macros because the commands I wanted them to execute were basic and it was easier to do on macros. If I needed to, I could easily convert them to VBA code. Let me know what you think. I'm gonna start making my other tables. I didn't focus on color schemes and palettes just yet. I'm gonna make the individual forms then make a main navigation form so I can format the colors. Is that a good idea?
 
This part...

Code:
 Exit_SmartFormError:
    Exit Sub
SmartFormError:
    If Err = 2046 Or Err = 2501 Then
        Resume Next
    Else
        MsgBox Err.Description
        Resume Exit_SmartFormError
    End If
End Sub

Error 2046 is the typical error you get when moving thru the records and reaching the end.

Error 2501 is another typical error you may receive stating the OpenForm was cancelled or some such nonsense.

To avoid those errors when a User is moving the records I tools Access to ignore them and keep doing what your doing BUT if you are at the beginning or the end just stop, no message, just stop. However, if there is another Error not trapped above, then show the User that Error.
 
This part...

Code:
 Exit_SmartFormError:
    Exit Sub
SmartFormError:
    If Err = 2046 Or Err = 2501 Then
        Resume Next
    Else
        MsgBox Err.Description
        Resume Exit_SmartFormError
    End If
End Sub

Error 2046 is the typical error you get when moving thru the records and reaching the end.

Error 2501 is another typical error you may receive stating the OpenForm was cancelled or some such nonsense.

To avoid those errors when a User is moving the records I tools Access to ignore them and keep doing what your doing BUT if you are at the beginning or the end just stop, no message, just stop. However, if there is another Error not trapped above, then show the User that Error.

Okay, noted. Thank you so much! I have posted my update. If you're not too busy, could maybe take a look at the code and let me know if it made sense. Lol.
 
I hope you don't have too many Forms because waiting till the end to *color* them would only make sense if that is true. As I said before I get the Form almost to the point of perfection, colors and all, and then I move on to the next one. But I usually build databases with well over 30 Forms and I'm not going back to color anything. When I'm done with it...it's done.

The balance looks great, well, except for the Macros, I don't do Macros because I have no control over the messages or over anything else I want them to do. Here's what I use for Navigation Buttons...
http://regina-whipp.com/blog/?p=538
 
I did look at your sample and it looks like we posted at the same time. So, I am posting this so you get another notification!
 
I have a few questions. I am making a form for t_Department. I want it to be a combination of the form and a table showing the employees under a certain department. Do you think it's better to do it that way? Or should I just make a for only for department, then make a query for the employees per department? I hope I'm making sense.

Thank you!
 
You really don't need a Form to show which Employee is in what Department you can use a Report for that. You already have a Form for Employees just make a Form to enter/edit Departments.
 
Hey! This is what I have so far. I don't really think that I'll have more than fifteen forms. So I'm just going to leave the colors as is until I decide what color scheme to apply.

So, what do you think should I do next? Do I make the forms for the other tables now? :)

View attachment X v4.2.accdb
 

Users who are viewing this thread

Back
Top Bottom