Solved

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

Posted on 2013-06-24
5
543 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 50

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 50

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 50

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

690 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