Not in List Error after replacing Chr(), yet added to list correctly










0















I have some combo boxes with code for adding new items to the source table with a form when it doesn't exist.



The code will replace Chr(47) / and Chr(92) with Chr(45) - if present. This is done because a file name is created using concatenation later.



The problem is if a character is replaced, I get an Access error that the item is not in the list. This does not happen if a character is not replaced. In both instances the correct items are added to the corresponding tables.



I have tried replacing the character before passing it to OpenArgs, AfterUpdate, on the form after it opens, etc. The error does not break so the program is working, I just want to eliminate a unnecessary pop-up message.



Any help is greatly appreciated.



Private Sub cboManual_NotInList(NewData As String, Response As Integer)
Dim MyMessage As String
Dim myButtons As Integer
Dim myTitle As String
Dim strSQL As String

On Error GoTo ErrHandler

MyMessage = "This Manual does not exist. Create it?"
myButtons = vbYesNo + vbDefaultButton1 + vbQuestion + vbApplicationModal
myTitle = "Add Manual?"
MyChoice = MsgBox(MyMessage, myButtons, myTitle)

If MyChoice = 6 Then
If Not DBAuthority = "Admin" And Not DBAuthority = "Data Entry" Then
Response = acDataErrContinue
MsgBox "Sorry, authorized access only", _
vbOKOnly, "Important Information"
Exit Sub
Else
Response = acDataErrAdded
CallerField = "Manual"
CallerForm = "NewDocument"
NewData = Replace(NewData, Chr(47), Chr(45))
NewData = Replace(NewData, Chr(92), Chr(45))
DoCmd.OpenForm "AddManual", windowmode:=acDialog, OpenArgs:=NewData
Me.cboManual.RowSource = Me.cboManual.RowSource
Me.cboManual.value = strAddManual
strManual = Me.cboManual.value
strAddManual = vbNullString
Me.cboSection.value = strAddSection
strSection = Me.cboSection.value
strAddSection = vbNullString
Me.cboEngine.value = strAddEngine
strEngine = Me.cboEngine.value
strAddEngine = vbNullString
End If
ElseIf MyChoice = 7 Then
Response = acDataErrContinue
MsgBox "Select Manual from list.", vbOKOnly, "Select Manual"
Me.cboManual.Undo
Me.cboManual.SetFocus
Exit Sub
End If
Exit Sub

ErrHandler:
If Err = 20 Then
Response = acDataErrContinue
ElseIf Err = 94 Then
Response = acDataErrContinue
Resume Next
ElseIf Err = 2237 Then
Response = acDataErrContinue
Resume Next
ElseIf Err = 0 Then
Response = acDataErrContinue
Else
MsgBox "cboManual.NotInList Err = " & Err.Number & " :" & Err.Description
Exit Sub
End If
Exit Sub
End Sub









share|improve this question
























  • You can't modify the new data. You should probably use keyDown event and replace while typed.

    – krish KM
    Nov 15 '18 at 13:22











  • @krish KM: I have a KeyDown event that will expand the dropdown menu if the down arrow is used. Would I be better off adding in an ElseIf or maybe a KeyPress Event? What would use less resources?

    – DyannaM
    Nov 15 '18 at 14:18











  • use select case in keydown event and do the replacements.

    – krish KM
    Nov 15 '18 at 14:20











  • @krish KM: I'm sorry, I'm completely self taught and have never used that before. Could you give me an example please?

    – DyannaM
    Nov 15 '18 at 14:24















0















I have some combo boxes with code for adding new items to the source table with a form when it doesn't exist.



The code will replace Chr(47) / and Chr(92) with Chr(45) - if present. This is done because a file name is created using concatenation later.



The problem is if a character is replaced, I get an Access error that the item is not in the list. This does not happen if a character is not replaced. In both instances the correct items are added to the corresponding tables.



I have tried replacing the character before passing it to OpenArgs, AfterUpdate, on the form after it opens, etc. The error does not break so the program is working, I just want to eliminate a unnecessary pop-up message.



Any help is greatly appreciated.



Private Sub cboManual_NotInList(NewData As String, Response As Integer)
Dim MyMessage As String
Dim myButtons As Integer
Dim myTitle As String
Dim strSQL As String

On Error GoTo ErrHandler

MyMessage = "This Manual does not exist. Create it?"
myButtons = vbYesNo + vbDefaultButton1 + vbQuestion + vbApplicationModal
myTitle = "Add Manual?"
MyChoice = MsgBox(MyMessage, myButtons, myTitle)

If MyChoice = 6 Then
If Not DBAuthority = "Admin" And Not DBAuthority = "Data Entry" Then
Response = acDataErrContinue
MsgBox "Sorry, authorized access only", _
vbOKOnly, "Important Information"
Exit Sub
Else
Response = acDataErrAdded
CallerField = "Manual"
CallerForm = "NewDocument"
NewData = Replace(NewData, Chr(47), Chr(45))
NewData = Replace(NewData, Chr(92), Chr(45))
DoCmd.OpenForm "AddManual", windowmode:=acDialog, OpenArgs:=NewData
Me.cboManual.RowSource = Me.cboManual.RowSource
Me.cboManual.value = strAddManual
strManual = Me.cboManual.value
strAddManual = vbNullString
Me.cboSection.value = strAddSection
strSection = Me.cboSection.value
strAddSection = vbNullString
Me.cboEngine.value = strAddEngine
strEngine = Me.cboEngine.value
strAddEngine = vbNullString
End If
ElseIf MyChoice = 7 Then
Response = acDataErrContinue
MsgBox "Select Manual from list.", vbOKOnly, "Select Manual"
Me.cboManual.Undo
Me.cboManual.SetFocus
Exit Sub
End If
Exit Sub

ErrHandler:
If Err = 20 Then
Response = acDataErrContinue
ElseIf Err = 94 Then
Response = acDataErrContinue
Resume Next
ElseIf Err = 2237 Then
Response = acDataErrContinue
Resume Next
ElseIf Err = 0 Then
Response = acDataErrContinue
Else
MsgBox "cboManual.NotInList Err = " & Err.Number & " :" & Err.Description
Exit Sub
End If
Exit Sub
End Sub









share|improve this question
























  • You can't modify the new data. You should probably use keyDown event and replace while typed.

    – krish KM
    Nov 15 '18 at 13:22











  • @krish KM: I have a KeyDown event that will expand the dropdown menu if the down arrow is used. Would I be better off adding in an ElseIf or maybe a KeyPress Event? What would use less resources?

    – DyannaM
    Nov 15 '18 at 14:18











  • use select case in keydown event and do the replacements.

    – krish KM
    Nov 15 '18 at 14:20











  • @krish KM: I'm sorry, I'm completely self taught and have never used that before. Could you give me an example please?

    – DyannaM
    Nov 15 '18 at 14:24













0












0








0








I have some combo boxes with code for adding new items to the source table with a form when it doesn't exist.



The code will replace Chr(47) / and Chr(92) with Chr(45) - if present. This is done because a file name is created using concatenation later.



The problem is if a character is replaced, I get an Access error that the item is not in the list. This does not happen if a character is not replaced. In both instances the correct items are added to the corresponding tables.



I have tried replacing the character before passing it to OpenArgs, AfterUpdate, on the form after it opens, etc. The error does not break so the program is working, I just want to eliminate a unnecessary pop-up message.



Any help is greatly appreciated.



Private Sub cboManual_NotInList(NewData As String, Response As Integer)
Dim MyMessage As String
Dim myButtons As Integer
Dim myTitle As String
Dim strSQL As String

On Error GoTo ErrHandler

MyMessage = "This Manual does not exist. Create it?"
myButtons = vbYesNo + vbDefaultButton1 + vbQuestion + vbApplicationModal
myTitle = "Add Manual?"
MyChoice = MsgBox(MyMessage, myButtons, myTitle)

If MyChoice = 6 Then
If Not DBAuthority = "Admin" And Not DBAuthority = "Data Entry" Then
Response = acDataErrContinue
MsgBox "Sorry, authorized access only", _
vbOKOnly, "Important Information"
Exit Sub
Else
Response = acDataErrAdded
CallerField = "Manual"
CallerForm = "NewDocument"
NewData = Replace(NewData, Chr(47), Chr(45))
NewData = Replace(NewData, Chr(92), Chr(45))
DoCmd.OpenForm "AddManual", windowmode:=acDialog, OpenArgs:=NewData
Me.cboManual.RowSource = Me.cboManual.RowSource
Me.cboManual.value = strAddManual
strManual = Me.cboManual.value
strAddManual = vbNullString
Me.cboSection.value = strAddSection
strSection = Me.cboSection.value
strAddSection = vbNullString
Me.cboEngine.value = strAddEngine
strEngine = Me.cboEngine.value
strAddEngine = vbNullString
End If
ElseIf MyChoice = 7 Then
Response = acDataErrContinue
MsgBox "Select Manual from list.", vbOKOnly, "Select Manual"
Me.cboManual.Undo
Me.cboManual.SetFocus
Exit Sub
End If
Exit Sub

ErrHandler:
If Err = 20 Then
Response = acDataErrContinue
ElseIf Err = 94 Then
Response = acDataErrContinue
Resume Next
ElseIf Err = 2237 Then
Response = acDataErrContinue
Resume Next
ElseIf Err = 0 Then
Response = acDataErrContinue
Else
MsgBox "cboManual.NotInList Err = " & Err.Number & " :" & Err.Description
Exit Sub
End If
Exit Sub
End Sub









share|improve this question
















I have some combo boxes with code for adding new items to the source table with a form when it doesn't exist.



The code will replace Chr(47) / and Chr(92) with Chr(45) - if present. This is done because a file name is created using concatenation later.



The problem is if a character is replaced, I get an Access error that the item is not in the list. This does not happen if a character is not replaced. In both instances the correct items are added to the corresponding tables.



I have tried replacing the character before passing it to OpenArgs, AfterUpdate, on the form after it opens, etc. The error does not break so the program is working, I just want to eliminate a unnecessary pop-up message.



Any help is greatly appreciated.



Private Sub cboManual_NotInList(NewData As String, Response As Integer)
Dim MyMessage As String
Dim myButtons As Integer
Dim myTitle As String
Dim strSQL As String

On Error GoTo ErrHandler

MyMessage = "This Manual does not exist. Create it?"
myButtons = vbYesNo + vbDefaultButton1 + vbQuestion + vbApplicationModal
myTitle = "Add Manual?"
MyChoice = MsgBox(MyMessage, myButtons, myTitle)

If MyChoice = 6 Then
If Not DBAuthority = "Admin" And Not DBAuthority = "Data Entry" Then
Response = acDataErrContinue
MsgBox "Sorry, authorized access only", _
vbOKOnly, "Important Information"
Exit Sub
Else
Response = acDataErrAdded
CallerField = "Manual"
CallerForm = "NewDocument"
NewData = Replace(NewData, Chr(47), Chr(45))
NewData = Replace(NewData, Chr(92), Chr(45))
DoCmd.OpenForm "AddManual", windowmode:=acDialog, OpenArgs:=NewData
Me.cboManual.RowSource = Me.cboManual.RowSource
Me.cboManual.value = strAddManual
strManual = Me.cboManual.value
strAddManual = vbNullString
Me.cboSection.value = strAddSection
strSection = Me.cboSection.value
strAddSection = vbNullString
Me.cboEngine.value = strAddEngine
strEngine = Me.cboEngine.value
strAddEngine = vbNullString
End If
ElseIf MyChoice = 7 Then
Response = acDataErrContinue
MsgBox "Select Manual from list.", vbOKOnly, "Select Manual"
Me.cboManual.Undo
Me.cboManual.SetFocus
Exit Sub
End If
Exit Sub

ErrHandler:
If Err = 20 Then
Response = acDataErrContinue
ElseIf Err = 94 Then
Response = acDataErrContinue
Resume Next
ElseIf Err = 2237 Then
Response = acDataErrContinue
Resume Next
ElseIf Err = 0 Then
Response = acDataErrContinue
Else
MsgBox "cboManual.NotInList Err = " & Err.Number & " :" & Err.Description
Exit Sub
End If
Exit Sub
End Sub






vba ms-access access-vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 20:17









Lee Mac

4,33731541




4,33731541










asked Nov 14 '18 at 18:44









DyannaMDyannaM

915




915












  • You can't modify the new data. You should probably use keyDown event and replace while typed.

    – krish KM
    Nov 15 '18 at 13:22











  • @krish KM: I have a KeyDown event that will expand the dropdown menu if the down arrow is used. Would I be better off adding in an ElseIf or maybe a KeyPress Event? What would use less resources?

    – DyannaM
    Nov 15 '18 at 14:18











  • use select case in keydown event and do the replacements.

    – krish KM
    Nov 15 '18 at 14:20











  • @krish KM: I'm sorry, I'm completely self taught and have never used that before. Could you give me an example please?

    – DyannaM
    Nov 15 '18 at 14:24

















  • You can't modify the new data. You should probably use keyDown event and replace while typed.

    – krish KM
    Nov 15 '18 at 13:22











  • @krish KM: I have a KeyDown event that will expand the dropdown menu if the down arrow is used. Would I be better off adding in an ElseIf or maybe a KeyPress Event? What would use less resources?

    – DyannaM
    Nov 15 '18 at 14:18











  • use select case in keydown event and do the replacements.

    – krish KM
    Nov 15 '18 at 14:20











  • @krish KM: I'm sorry, I'm completely self taught and have never used that before. Could you give me an example please?

    – DyannaM
    Nov 15 '18 at 14:24
















You can't modify the new data. You should probably use keyDown event and replace while typed.

– krish KM
Nov 15 '18 at 13:22





You can't modify the new data. You should probably use keyDown event and replace while typed.

– krish KM
Nov 15 '18 at 13:22













@krish KM: I have a KeyDown event that will expand the dropdown menu if the down arrow is used. Would I be better off adding in an ElseIf or maybe a KeyPress Event? What would use less resources?

– DyannaM
Nov 15 '18 at 14:18





@krish KM: I have a KeyDown event that will expand the dropdown menu if the down arrow is used. Would I be better off adding in an ElseIf or maybe a KeyPress Event? What would use less resources?

– DyannaM
Nov 15 '18 at 14:18













use select case in keydown event and do the replacements.

– krish KM
Nov 15 '18 at 14:20





use select case in keydown event and do the replacements.

– krish KM
Nov 15 '18 at 14:20













@krish KM: I'm sorry, I'm completely self taught and have never used that before. Could you give me an example please?

– DyannaM
Nov 15 '18 at 14:24





@krish KM: I'm sorry, I'm completely self taught and have never used that before. Could you give me an example please?

– DyannaM
Nov 15 '18 at 14:24












2 Answers
2






active

oldest

votes


















0














Option one
Replace while typing



Select Case KeyCode
Case vbKeyDown
Me![cboNewPart].Dropdown
Case 220, 191 ' / and
KeyCode = 189 ' with -
Case Else
End Select


Option two
after adding the new value to the table. do



me.combo.undo, me.combo.requery. me.combo.value = newValue


followed by acDataErrContinue
this way you won't get error message but the list will flicker a and it's purely a hack.






share|improve this answer























  • @krich KM: You are wonderful! Thank you so much!

    – DyannaM
    Nov 15 '18 at 14:53


















0














Try using a different variable name (other than NewData) to store the modified version of the value passed to the NewData argument, i.e.:



Dim NewString as String
NewString = NewData
NewString = Replace(NewString, Chr(47), Chr(45))
NewString = Replace(NewString, Chr(92), Chr(45))
DoCmd.OpenForm "AddManual", windowmode:=acDialog, OpenArgs:=NewString


Since VBA arguments are passed ByRef unless otherwise stated, any modification to the argument value will be modifying the original value passed to your cboManual_NotInList event handler.




Given the above, you could alternatively try changing the NewData argument to be passed by value (ByVal):



Private Sub cboManual_NotInList(ByVal NewData As String, Response As Integer)





share|improve this answer

























  • Unfortunately same result. Error if a character is replaced, no error when there are no characters replaced. Both are still added correctly though.

    – DyannaM
    Nov 14 '18 at 19:13











  • Does the error give any indication of the VBA expression which is causing it?

    – Lee Mac
    Nov 14 '18 at 19:28











  • No. It's just a generic Access message. How can I add a screen shot here?

    – DyannaM
    Nov 14 '18 at 19:44












  • @DyannaM I have edited my answer above

    – Lee Mac
    Nov 14 '18 at 19:47











  • @DyannaM: You can copy the content (the text) of an Access error message to the clipboard by pressing Ctrl-c when it's shown and then past the relevant part here. That applies for simple MsgBoxs too.

    – Unhandled Exception
    Nov 14 '18 at 19:52











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53306851%2fnot-in-list-error-after-replacing-chr-yet-added-to-list-correctly%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Option one
Replace while typing



Select Case KeyCode
Case vbKeyDown
Me![cboNewPart].Dropdown
Case 220, 191 ' / and
KeyCode = 189 ' with -
Case Else
End Select


Option two
after adding the new value to the table. do



me.combo.undo, me.combo.requery. me.combo.value = newValue


followed by acDataErrContinue
this way you won't get error message but the list will flicker a and it's purely a hack.






share|improve this answer























  • @krich KM: You are wonderful! Thank you so much!

    – DyannaM
    Nov 15 '18 at 14:53















0














Option one
Replace while typing



Select Case KeyCode
Case vbKeyDown
Me![cboNewPart].Dropdown
Case 220, 191 ' / and
KeyCode = 189 ' with -
Case Else
End Select


Option two
after adding the new value to the table. do



me.combo.undo, me.combo.requery. me.combo.value = newValue


followed by acDataErrContinue
this way you won't get error message but the list will flicker a and it's purely a hack.






share|improve this answer























  • @krich KM: You are wonderful! Thank you so much!

    – DyannaM
    Nov 15 '18 at 14:53













0












0








0







Option one
Replace while typing



Select Case KeyCode
Case vbKeyDown
Me![cboNewPart].Dropdown
Case 220, 191 ' / and
KeyCode = 189 ' with -
Case Else
End Select


Option two
after adding the new value to the table. do



me.combo.undo, me.combo.requery. me.combo.value = newValue


followed by acDataErrContinue
this way you won't get error message but the list will flicker a and it's purely a hack.






share|improve this answer













Option one
Replace while typing



Select Case KeyCode
Case vbKeyDown
Me![cboNewPart].Dropdown
Case 220, 191 ' / and
KeyCode = 189 ' with -
Case Else
End Select


Option two
after adding the new value to the table. do



me.combo.undo, me.combo.requery. me.combo.value = newValue


followed by acDataErrContinue
this way you won't get error message but the list will flicker a and it's purely a hack.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 14:40









krish KMkrish KM

4,1851727




4,1851727












  • @krich KM: You are wonderful! Thank you so much!

    – DyannaM
    Nov 15 '18 at 14:53

















  • @krich KM: You are wonderful! Thank you so much!

    – DyannaM
    Nov 15 '18 at 14:53
















@krich KM: You are wonderful! Thank you so much!

– DyannaM
Nov 15 '18 at 14:53





@krich KM: You are wonderful! Thank you so much!

– DyannaM
Nov 15 '18 at 14:53













0














Try using a different variable name (other than NewData) to store the modified version of the value passed to the NewData argument, i.e.:



Dim NewString as String
NewString = NewData
NewString = Replace(NewString, Chr(47), Chr(45))
NewString = Replace(NewString, Chr(92), Chr(45))
DoCmd.OpenForm "AddManual", windowmode:=acDialog, OpenArgs:=NewString


Since VBA arguments are passed ByRef unless otherwise stated, any modification to the argument value will be modifying the original value passed to your cboManual_NotInList event handler.




Given the above, you could alternatively try changing the NewData argument to be passed by value (ByVal):



Private Sub cboManual_NotInList(ByVal NewData As String, Response As Integer)





share|improve this answer

























  • Unfortunately same result. Error if a character is replaced, no error when there are no characters replaced. Both are still added correctly though.

    – DyannaM
    Nov 14 '18 at 19:13











  • Does the error give any indication of the VBA expression which is causing it?

    – Lee Mac
    Nov 14 '18 at 19:28











  • No. It's just a generic Access message. How can I add a screen shot here?

    – DyannaM
    Nov 14 '18 at 19:44












  • @DyannaM I have edited my answer above

    – Lee Mac
    Nov 14 '18 at 19:47











  • @DyannaM: You can copy the content (the text) of an Access error message to the clipboard by pressing Ctrl-c when it's shown and then past the relevant part here. That applies for simple MsgBoxs too.

    – Unhandled Exception
    Nov 14 '18 at 19:52
















0














Try using a different variable name (other than NewData) to store the modified version of the value passed to the NewData argument, i.e.:



Dim NewString as String
NewString = NewData
NewString = Replace(NewString, Chr(47), Chr(45))
NewString = Replace(NewString, Chr(92), Chr(45))
DoCmd.OpenForm "AddManual", windowmode:=acDialog, OpenArgs:=NewString


Since VBA arguments are passed ByRef unless otherwise stated, any modification to the argument value will be modifying the original value passed to your cboManual_NotInList event handler.




Given the above, you could alternatively try changing the NewData argument to be passed by value (ByVal):



Private Sub cboManual_NotInList(ByVal NewData As String, Response As Integer)





share|improve this answer

























  • Unfortunately same result. Error if a character is replaced, no error when there are no characters replaced. Both are still added correctly though.

    – DyannaM
    Nov 14 '18 at 19:13











  • Does the error give any indication of the VBA expression which is causing it?

    – Lee Mac
    Nov 14 '18 at 19:28











  • No. It's just a generic Access message. How can I add a screen shot here?

    – DyannaM
    Nov 14 '18 at 19:44












  • @DyannaM I have edited my answer above

    – Lee Mac
    Nov 14 '18 at 19:47











  • @DyannaM: You can copy the content (the text) of an Access error message to the clipboard by pressing Ctrl-c when it's shown and then past the relevant part here. That applies for simple MsgBoxs too.

    – Unhandled Exception
    Nov 14 '18 at 19:52














0












0








0







Try using a different variable name (other than NewData) to store the modified version of the value passed to the NewData argument, i.e.:



Dim NewString as String
NewString = NewData
NewString = Replace(NewString, Chr(47), Chr(45))
NewString = Replace(NewString, Chr(92), Chr(45))
DoCmd.OpenForm "AddManual", windowmode:=acDialog, OpenArgs:=NewString


Since VBA arguments are passed ByRef unless otherwise stated, any modification to the argument value will be modifying the original value passed to your cboManual_NotInList event handler.




Given the above, you could alternatively try changing the NewData argument to be passed by value (ByVal):



Private Sub cboManual_NotInList(ByVal NewData As String, Response As Integer)





share|improve this answer















Try using a different variable name (other than NewData) to store the modified version of the value passed to the NewData argument, i.e.:



Dim NewString as String
NewString = NewData
NewString = Replace(NewString, Chr(47), Chr(45))
NewString = Replace(NewString, Chr(92), Chr(45))
DoCmd.OpenForm "AddManual", windowmode:=acDialog, OpenArgs:=NewString


Since VBA arguments are passed ByRef unless otherwise stated, any modification to the argument value will be modifying the original value passed to your cboManual_NotInList event handler.




Given the above, you could alternatively try changing the NewData argument to be passed by value (ByVal):



Private Sub cboManual_NotInList(ByVal NewData As String, Response As Integer)






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 14 '18 at 19:47

























answered Nov 14 '18 at 18:59









Lee MacLee Mac

4,33731541




4,33731541












  • Unfortunately same result. Error if a character is replaced, no error when there are no characters replaced. Both are still added correctly though.

    – DyannaM
    Nov 14 '18 at 19:13











  • Does the error give any indication of the VBA expression which is causing it?

    – Lee Mac
    Nov 14 '18 at 19:28











  • No. It's just a generic Access message. How can I add a screen shot here?

    – DyannaM
    Nov 14 '18 at 19:44












  • @DyannaM I have edited my answer above

    – Lee Mac
    Nov 14 '18 at 19:47











  • @DyannaM: You can copy the content (the text) of an Access error message to the clipboard by pressing Ctrl-c when it's shown and then past the relevant part here. That applies for simple MsgBoxs too.

    – Unhandled Exception
    Nov 14 '18 at 19:52


















  • Unfortunately same result. Error if a character is replaced, no error when there are no characters replaced. Both are still added correctly though.

    – DyannaM
    Nov 14 '18 at 19:13











  • Does the error give any indication of the VBA expression which is causing it?

    – Lee Mac
    Nov 14 '18 at 19:28











  • No. It's just a generic Access message. How can I add a screen shot here?

    – DyannaM
    Nov 14 '18 at 19:44












  • @DyannaM I have edited my answer above

    – Lee Mac
    Nov 14 '18 at 19:47











  • @DyannaM: You can copy the content (the text) of an Access error message to the clipboard by pressing Ctrl-c when it's shown and then past the relevant part here. That applies for simple MsgBoxs too.

    – Unhandled Exception
    Nov 14 '18 at 19:52

















Unfortunately same result. Error if a character is replaced, no error when there are no characters replaced. Both are still added correctly though.

– DyannaM
Nov 14 '18 at 19:13





Unfortunately same result. Error if a character is replaced, no error when there are no characters replaced. Both are still added correctly though.

– DyannaM
Nov 14 '18 at 19:13













Does the error give any indication of the VBA expression which is causing it?

– Lee Mac
Nov 14 '18 at 19:28





Does the error give any indication of the VBA expression which is causing it?

– Lee Mac
Nov 14 '18 at 19:28













No. It's just a generic Access message. How can I add a screen shot here?

– DyannaM
Nov 14 '18 at 19:44






No. It's just a generic Access message. How can I add a screen shot here?

– DyannaM
Nov 14 '18 at 19:44














@DyannaM I have edited my answer above

– Lee Mac
Nov 14 '18 at 19:47





@DyannaM I have edited my answer above

– Lee Mac
Nov 14 '18 at 19:47













@DyannaM: You can copy the content (the text) of an Access error message to the clipboard by pressing Ctrl-c when it's shown and then past the relevant part here. That applies for simple MsgBoxs too.

– Unhandled Exception
Nov 14 '18 at 19:52






@DyannaM: You can copy the content (the text) of an Access error message to the clipboard by pressing Ctrl-c when it's shown and then past the relevant part here. That applies for simple MsgBoxs too.

– Unhandled Exception
Nov 14 '18 at 19:52


















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53306851%2fnot-in-list-error-after-replacing-chr-yet-added-to-list-correctly%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

Evgeni Malkin