Question Query Result Shown In Message Box

AccessNewBoy

Registered User.
Local time
Today, 07:37
Joined
Mar 11, 2009
Messages
19
Hello all,
I could do with some help on the attached Database, it is not the full project but i have scaled it down so i can attach it.

I have a Query that is set to look at the name inputted on the main form and if it is their Birthday it shows the entry on the query. If not the query is blank.

What i am looking for is a piece of code that will run the Query (DLookup, i think) and if the query is positive then a message box will appear something like this:

Happy Birthday "Name returned from Query".

I hope i am making some sense and i am grateful for any assistance.
 

Attachments

In stead of using a text box why not use a Combo Box? That way you can pick up the DOB as a hidden column in the combo box row source and use the following;

Code:
If DateDiff("d", Date, Me.Combo3.Column(2)) = 0 Then
        MsgBox "Happy Birthday " & Me.Combo3.Column(1)
End If

As part of the code behind a Log In button.
 

Attachments

In stead of using a text box why not use a Combo Box? That way you can pick up the DOB as a hidden column in the combo box row source and use the following;

Code:
If DateDiff("d", Date, Me.Combo3.Column(2)) = 0 Then
        MsgBox "Happy Birthday " & Me.Combo3.Column(1)
End If

As part of the code behind a Log In button.


Hi John,
Thanks for taking the time to look at this however i cant use a Combo Box and can only use a Textbox due to how the Database already is set up.

Thanks for taking the time to look.
 
See if this does it for you. Type in the name and hit your enter key.


Hi Bob,
this is what i need apart from just one thing. I need it to show the persons name in the message box:

Happy Birthday Matt

Either way thanks for taking the time to help.
 
Hi Bob,
this is what i need apart from just one thing. I need it to show the persons name in the message box:

Happy Birthday Matt

Either way thanks for taking the time to help.

Download it again, I had realized that and uploaded a new version but you probably downloaded before I got it up.
 
Download it again, I had realized that and uploaded a new version but you probably downloaded before I got it up.



Bob,
This is just what i need, i have been spending a large part of the day trying to create a piece of code looking at using a DCount and even a DLookup without any success.
It was my intention to post the code i had done as i wanted to show people i was trying to do it on my own but i thought it would just complicate things.

Thanks again.


Matt
 
Last edited:
Hi John,
Thanks for taking the time to look at this however i cant use a Combo Box and can only use a Textbox due to how the Database already is set up.

Thanks for taking the time to look.

I'm sorry, but I fail to see why the structure of your DB would prevent you from implementing a solution such as I have suggested.

Whilst I understand that it was not what you might have envisaged, it has the advantage that the user can simply select his userID from a list rather than risk miskeying it. I can image no data structure that would preclude the us of my solution.
 
Well, it is a little more secure since a user needs to know his ID and someone else could only guess. Not that anything is really secure in there but that is one reason why someone might want to have it typed in. Personally, I would rather just tie it to their Network ID and automatically log them in based on that. It is up to them to keep their machine from being accessed by non-authorized personnel and so if they have logged on to their machine, we can pretty much use that as the authority. But, if there are shared machines that might make a difference.

Anyway, JBB - the selection from a combo would be simpler, and easier, from a user perspective. It would be good to know what the constraints are and how they got in place. But in the end, they can do whatever they want, even if it doesn't make sense to our thinking. :)
 
....... in the end, they can do whatever they want, even if it doesn't make sense to our thinking. :)

Too true :eek:

I've spent the better part of the day mulling this over, and curiosity finally got the better of me.
 
......, and curiosity finally got the better of me.

Given that curiosity KILLED the cat, and missinglinq is found of say "There's always more than one way to SKIN a cat". I guess that missinglinq will have a new and imaginative way to skin me :D
 
JBB,
I thinks its fare to say your experience in Access supersedes mine. The reason i wanted to use a Text box and not a combo box is that the likely hood of someone guessing a password is high as most office people use a pets name, Childs name or something simple. Compared to the likely hood of a person guessing a user name as well as their password is less likely just as Boblarson said. Also Boblarson the reason why i did not use the Network id is just as you thought, we use whats called generic logins at work where each department has one login to use. so with all this in mind a Textbox would be the most secure and comon sense approach.
I am sure if i had the confidence and experience of you both i would be more willing to experiment with things but as its finally working after much needed and appreciated help from you both i am somewhat unwilling to tinker with it due to my deadline.
Also from looking at some of the sample database on here that deal with logins by users like unclegizmo they all seem to use a textbox to login.

Thanks again
 
JBB,
...................... Compared to the likely hood of a person guessing a user name as well as their password is less likely just as Boblarson said. ..........

I would have thought that if you know how your own UserID is constructed, working out what someone else's looks like wouldn't be a huge leap. Some of the commercial applications I work with retain the last users, userID between sessions, so that puts paid to that argument.

In the end however you need to use what you feel is the best opption for your situation.
 
I would have thought that if you know how your own UserID is constructed, working out what someone else's looks like wouldn't be a huge leap. Some of the commercial applications I work with retain the last users, userID between sessions, so that puts paid to that argument.

In the end however you need to use what you feel is the best opption for your situation.

Thanks for the assistance, like i said i am just getting to know Access and your help and suggestions along with boblarson is very much needed and appreciated.
 

Users who are viewing this thread

Back
Top Bottom