Solved

Message Box to pass value from user to code...

Posted on 2013-06-24
5
498 Views
Last Modified: 2013-06-24
I am trying to add message box that will pop up and ask user to describe type of entry than pass that data to the code'''

Private Sub Command152_Click()
Dim RS   As Recordset
Set RS = CurrentDb.OpenRecordset("PscTable", dbOpenDynaset, dbSeeChanges)
RS.AddNew
RS![OldItem] = Item.Value
RS![Date] = Format(Now(), "mm/dd/yyyy")

MsgBox “Describe Function”

RS![Class] = ‘Imput From Msgbox here


RS![Employee] = LogIn.Value
'RS![EmpId] = "201"
RS![TotalHours] = ReadIniFile("H:\Generald\GDB.ini", "Contact Values", "AdminFunction", "")
RS![MonthHidden] = Format(Now(), "mm")
RS![DayHidden] = Format(Now(), "dd")
RS![YearHidden] = Format(Now(), "yyyy")
RS.Update
RS.Close
Set RS = Nothing
        'End Write times
MsgBox " Admin Function was logged Successfully", vkokonly, "Activity System"

End Sub
0
Comment
Question by:mickeyshelley1
  • 3
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 39272107
It is the InputBox you are looking for, not MessageBox.

/gustav
0
 

Author Comment

by:mickeyshelley1
ID: 39272111
Thank you
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 39272147
Just remember, that if the user cancels the InputBox, it will return a zero-length string: ""

So your code should check that condition before proceeding or before passing the value to RS![Class] ... except, of course if this acceptable. However, if the field can be empty, this will usually be Null, which means that if no name is given, a Null should be passed to RS![Class]:

  RS![Class] = IIf(strInput = "", Null, strInput)

/gustav
0
 

Author Comment

by:mickeyshelley1
ID: 39272497
How can i get it to exit sub if the user cancels the inputbox?

Dim RS   As Recordset
Set RS = CurrentDb.OpenRecordset("PscTable", dbOpenDynaset, dbSeeChanges)
RS.AddNew
RS![OldItem] = Item.Value
RS![Date] = Format(Now(), "mm/dd/yyyy")
RS![Class] = InputBox("Please Describe Admin Function:", "Additional Info Needed")
RS![Employee] = LogIn.Value
'RS![EmpId] = "201"
RS![TotalHours] = ReadIniFile("H:\Generald\GDB.ini", "Contact Values", "AdminFunction", "")
RS![MonthHidden] = Format(Now(), "mm")
RS![DayHidden] = Format(Now(), "dd")
RS![YearHidden] = Format(Now(), "yyyy")
RS.Update
RS.Close
Set RS = Nothing
        'End Write times
MsgBox " Admin Function was logged Successfully", vkokonly, "Activity System"

Open in new window

0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 39272636
Something like:

Dim RS   As Recordset
Dim strInput As String

Set RS = CurrentDb.OpenRecordset("PscTable", dbOpenDynaset, dbSeeChanges)
strInput = InputBox("Please Describe Admin Function:", "Additional Info Needed")
If strInput = "" Then
    ' Skip adding record.
    MsgBox " Admin Function was not logged.", vkokonly, "Activity System"
Else
    RS.AddNew
    ' ....
    RS![Class] = strInput
...

/gustav
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now