mickeyshelley1
asked on
Message Box to pass value from user to code...
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("P scTable", 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\G DB.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
Private Sub Command152_Click()
Dim RS As Recordset
Set RS = CurrentDb.OpenRecordset("P
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\G
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
ASKER
Thank you
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
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
ASKER
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"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
/gustav