I want to be able to type a word like "FREIGHT" in a text box on a form and have the word "FREIGHT" be automatically entered in the form code after tblAmount. Anyone know how to do this? Thanks
Form Event Procedure Code
strNewText = "tblAmount.[FREIGHT]
Hi,
Now that you got it working for the Num-1 text box, I'd like to be able to have 5 text boxes, Num-1 through Num-5 that I could fill in. Then when I hit enter, it would change the Module Code in 5 places.
Would you know how to set it up so it could search and replace 5 items instead of just one?
Thanks
Below is the Form Event Procedure Code
Option Compare Database
Option Explicit
Dim MyModule As Module
Private Sub Command0_Click()
Dim StartLine As Long, StartColumn As Long
Dim EndLine As Long, EndColumn As Long
Dim strLine As String, strNewLine As String
Dim intChr As Integer, intBefore As Integer, intAfter As Integer
Dim strLeft As String, strRight As String
Dim strSearchText As String, strNewText
' The string you are searching for is:
strSearchText = "tblStupload.[NUM-1]"
' The replacement string is:
strNewText = "tblAmount.[" & [Text1] & "]"
' Open the Module you want to modify.
DoCmd.OpenModule "mdlDoItAll"
' Set the Created Code Modules as the Object.
Set MyModule = Application.Modules("mdlDoItAll")
' Search for string.
If MyModule.Find(strSearchText, StartLine, StartColumn, EndLine, _
EndColumn) Then
' Store text of line containing string.
strLine = MyModule.Lines(StartLine, Abs(EndLine - StartLine) + 1)
' Determine length of line.
intChr = Len(strLine)
' Determine number of characters preceding search text.
intBefore = StartColumn - 1
' Determine number of characters following search text.
intAfter = intChr - CInt(EndColumn - 1)
' Store characters to left of search text.
strLeft = Left$(strLine, intBefore)
' Store characters to right of search text.
strRight = Right$(strLine, intAfter)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.