Enter Parameter Value?

Insentive

Registered User.
Local time
Today, 01:51
Joined
Mar 12, 2008
Messages
13
Need some help, in the following code i want a input box to pop up and request the user enter a valuee that will replace a previous one (amending). Currently after a press "ok" on the inputbox it askes me for the parameter value of the value i typed into the inputbox (not the variable). i dotn know what is the problem, can anybody help me out?
Code:
Private Sub CmdAmend_Click()
On Error GoTo Err_CmdAmend_Click
Dim strAmendNew As Variant
Dim strAmendOld As String
Dim PosId As Integer
Dim strSQL As String
Dim ErrMsg As String
Dim SuccessMsg As String
Dim NullCheck As String

PosId = Me.List3.Value
strAmendOld = DLookup("[Position]", "Positions", "[ID] = " & PosId)
strAmendNew = InputBox("Enter New Data", "Position Amend", strAmendOld)

If IsNull(strAmendNew) = True Then
ErrMsg = MsgBox("You did not enter a value!", vbOKOnly, "Error!")
Else
    If IsNull(strAmendNew) = False Then
strSQL = "UPDATE Positions SET Position = " & strAmendNew & " WHERE ID = " & PosId & ";"
DoCmd.RunSQL strSQL
SuccessMsg = MsgBox("Amendment Successful", vbOKOnly, "Success!")
Me.List3.Requery
Else
ErrMsg = MsgBox("Something went wrong!", vbOKOnly, "Could not complete request")
End If
End If
 
Try putting single quotes before and after your string:

Code:
strSQL = "UPDATE Positions SET Position = '" & strAmendNew & "' WHERE ID = " & PosId & ";"

You may have other problems, but whenever you use a String this way it needs enclosed in quotes - single quotes act just like double-quotes would if they weren't special charaters.

Also, instead of:

Code:
If Isnull(strAmendNew) = True     or    IsNull(strAmendNew) = False
you can just say:
Code:
If isnull(strAmendNew)        or   Not Isnull(strAmendNew)

But that's just cosmetic.

Hope this helps,
Evan
 

Users who are viewing this thread

Back
Top Bottom