Modules & VBA :: Display All Until A Special Character Is Found
Feb 3, 2014
L=Letter , X=number. Examples consisting of three parts (it can be more than three).
1. LLLLXXXXXX_LLLLXXXXXX_LLLLXXXXXX
OR
2. LLLLXXXXXX LLLLXXXXXX LLLLXXXXXX
OR
3. LLLLXXXXXX&LLLLXXXXXX&LLLLXXXXXX
OR
4. LLLL_LLLLXXXXXX&LLLLXXXXXX
OR
5. LL LLLLXXXXXX&LLLLXXXXXX
I would like to develop a function that takes a string that is made up of three parts or more and each part is separated by an underscore "_", space, or "&". There is no character that takes precedence over the other. It will always be only a single character which seperates the parts.
The check will always be done from the left. It should carry out the following actions:
1. Display all characters from the left until it reaches the first seperator "_" underscore OR "space" or "&"
2. Check only Part1 if it is made up of 4 letters and the rest 6 numbers (see 1-3 above). If that is the case only return part 1.
3. If part one only has letters and no numbers (see above 4-5) return all parts. Part one can consist of two letters or more.
I have started the function for step 1 above that searches for the character "_" underscore and display all characters until the first "_" is reached. I would like to include the same for "Space" or "&" in this function.
Once that is done I would like to do step 2 and step 3.
Code:
Function SearchforChar(strTest As String) As String
Dim test2 As String
Dim strUntil As String
strUntil = "_"
test2 = Left(strTest, InStr(1, strTest, strUntil) - 1)
[Code] ....
Answer3:
Full name with all parts should be returned for all above four cases under situation 3.
I'm trying to paste the values of worksheet 1 by value. Please see the attached two files.
When I run the code, it indicates that variable ( xlpastevalues) is not defined.
It is not a variable....
Code: Private Sub Command0_Click() Dim xlApp As Object Set xlApp = CreateObject("Excel.Application") xlApp.Visible = True xlApp.Workbooks.Open "Your locationmetric_DEV.xls", True, False With xlApp.activeworkbook.worksheets("Metric summary") .usedrange.copy .range("A1").pasteSpecial paste:=xlPasteValues End With End Sub
We have a spreadsheet that i upload onto a table, i use on of the fields to build a file path but if there is a special character it causes problems,i need to replace the below with spaces if they are in my field called path
I am building a database for a client who manufactures car parts. I have a table to store vehicle model. Each model has a date range of production. I have two build dates from and to. Both of these fields are setup as date fields on the table. I made both fields required with a mask for validation. In the "build date to" field if a car is still in production I need to leave the field blank. Is there any special character that will allow me to store a required field blank.
I have a numeric field from a SQL database that is not editable. I need to limit the number of characters displayed when I bring that field into Access forms and reports. I want it to only display the last 4 digits.
I have a macro in the On No Data event of a report that displays a message when the item number a user requests does not exist in the table being queried.
Now I need to get the same functionality in a form. The form is based on a parameter query with only one criteria [Please enter item number]. The form opens in Edit mode when a valid item number is entered.
I see that there is no On No Data event for either forms or queries, so I'm stumped on how to proceed.
How to make an input mask display more than one character?I'm building a db for work, and multiple (non-IT) people will enter data. Instead of having the input mask for the date field display as ##-###-####, I would like it to display as DD-MMM-YYYY.
I am not sure where to start or go about creating message box that would display "No results found" if my queries return no results. My search of the forums hasn't been fruitful.
I have created one form that has a text box and a button that works as a search function to run through the tables and displays the applicable queries. Currently, if no results are returned nothing happens. Preferably I would like a message box to display stating that there were "No results found". I would assume that the code would be associated with the "Find" button. Here is the VBA code as it stands, again, I haven't even attempted to add code for a message box.
Private Sub Find_Click() On Error GoTo Find_Click_Err
If DCount("Heading", "Service Desk Manual Query") > 0 Then DoCmd.OpenQuery "Service Desk Manual Query", acViewNormal, acReadOnly End If
I have a Memo field that is used to be a description of a document. I don't know what the user will put in (could be anything), but it is eventually passed in a string to a query, etc.I discovered during testing that if an apostrophe is entered (Ex: This document explains how to deal with Joe's pleasant disposition.), it breaks my code. I then realized that all reserved words and characters would cause this problem.
I can get around this one just by using Replace(str, "'", "''"). However, I know there are others that will cause problems, and I don't want to end up with a string of replace statements just to fix them.
the access database is about contracts.Each contract has an ID. So starting from ID1 to ID250. Right now i export in via VBA to excel. I have to create before in the excel the 250 tables. If the ID10 is not existing anymore i still have the table 10 left and then i have to delete this table.
Code: Dim xlSheet As Object 'Excel.Worksheet Dim rstID As DAO.Recordset, tmpStr As String Dim rstGr As DAO.Recordset, strSQL As String
I have a table called: "tb_special_characters" with a field name [character]. In this table are values that I would like to remove from fields in another table ("tb_data", field name [Title]
The values in the "tb_special_characters" are thinks like . @ }
I'd like to run a query on tb_data.title that would replace any matching characters in tb_special_characters.character with nothing (I remove and close any spaces).
In Access i can create different contracts with different running time.
I have contracts with a running time of 4 years, 6years, 8 years, 10 years and 12 years.
I have for each contract a different Excel file.
The users can choose via an Inputbox, which contract he wants to Export in Excel. In the Inputbox he enters the SuWID.
Now i want that the the Excel file with the Special running time get opened.
4 years ----> ("C:UsersGRIMBENDesktop4years.xlsm") 6 years ----> ("C:UsersGRIMBENDesktop6years.xlsm")
and so on.
Code: Dim xlApp As Object 'Excel.Application Dim xlBook As Object 'Excel.Workbook Dim xlSheet As Object 'Excel.Worksheet Dim rst As DAO.Recordset, SuWID As Long, tmpStr As String
I have an asset database I am designing to manage our computer inventory and assets.
I am trying to get a DLookup to work with one of my forms that will auto-populate some of the fields depending on what is entered in to the ProductID field. For instance, Make, Model, Asset type...
My problem is that the string that returns contains special characters, specifically "#" and gives me the error message -
Run-time error '3075': Syntax error in date in query expression 'productID=EN371UA#ABA'.
My expression is definitely working, it just looks like it things it has something to do with date/time which it does not. Unfortunately, most HP equipment contains a # in the Product ID number.
Here is my expression -
Private Sub ProductIDCombo_AfterUpdate() Make = DLookup("Make", "productlist", "productID=" & [ProductIDCombo]) End Sub
Make is the field I am looking up from the ProductList table. The Product ID is the ID I'm looking up from the ProductList table to find the make. My problem is actually getting it to return the correct value of "HP or Dell or Lenovo". etc.
Is it possible that two mgsbox will Show up, where the user can put in the timeperiod.
The time period would be the starting day of the contract.
It's called inception_date
Code: Private Sub Befehl1_Click() Dim xlApp As Object 'Excel.Application Dim xlBook As Object 'Excel.Workbook Dim xlSheet As Object 'Excel.Worksheet Dim rstID As DAO.Recordset, tmpStr As String Dim rstGr As DAO.Recordset, strSQL As String
I have a problem with my database I have a combo box that will search for my record. Actually its working I input the specific number it goes to the specific record. But I want, if there no existing record in my database it will display a Messagebox that "No record Found" I try to put a code in a macro builder in a after update property field but nothing happened.
Expression code that it will display the msgbox if there's no record found.
the given code from macro builder is attached. I try to have an if else statement but I dont know how to not equal that giver conditional expression.
In the access form I want to add a button with a special functionality.
After clicking "Select file" button special window should be open (or something else). It should give user a possibility of files locating (doc, pdf, rtf, txt ...).
After selecting the file and confirm the choice in the table "File_location" in database path to the file should be saved .
I will try and keep this brief. I have a paragraph of text, I have to paste it into a system which allows me 75 characters in a line and 208 in a page.
I have code which creates text boxes dynamically based on the total amount of characters/208 - this gives me how many textboxes need creating. I also have code which then populates those textboxes 208 characters at a time. I now need to alter it so it puts a line break every 75 characters.
Code: Private Sub btnsubmit_Click() DoCmd.OpenForm "NoteForm", acDesign Dim x As Integer Dim ctrl As Control Dim y As Integer
[Code] ....
So I've achieved almost what I want, I just need to amend it so it starts a new line after every 75 characters...
The following is code to open a form and records with a specific date as input by the user:
Private Sub cmdDisplayCovers_Click() On Error GoTo Err_cmdDisplayCovers_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmInventory" stLinkCriteria = "[tblCovers].[Date] = [Forms]![frmCoversByDate]![txtDate]" DoCmd.OpenForm stDocName, , , stLinkCriteria etc. etc.
generate a message to user if no records match the input and then return to the input form. Currently, the form opens even with no records.
I have a program that has been working for a year or so, it imports records form a text file created by a web site. Someone has entered a hex("1A", "A8" in a name field. It is shutting my program down. I tried a alphanumeric check to replace it and a length check to try and skip the record but the program thinks it is at the end of the file and quits reading records. Is there a way to get rid of characters like this in vba?
"5407 MUYF3I23 GIS..LE "
Here is what I have tried
Code: If Len(strread) <> 591 Then MsgBox "Invalid Record Read " & strread GoTo Skip_Loop End If If AlphaNumeric(CStr(Trim(Mid(strread, 32, 11)))) Then !HT_FName = CStr(Trim(Mid(strread, 32, 11)))
Somehow it doesn't take this variable msoFileDialogSaveAs. It tells me it's unknown.
Code: Public Sub Command2_Click() On Error GoTo MyError3 Dim filelocation As Variant Dim g As Object Set g = Application.FileDialog(msoFileDialogSaveAs)
i have the following code in a function but when i want to compile it i have the following code will be blue i have error in this line:
.NamedParameters = True
the error message is this :
method or data member not found
my code is as following:
Function Get_Bearbeiter_Detail(ByVal vBearbeiter_Code As String, Optional ByRef vBearbeiter_Name As String, Optional ByRef vReadOnly_Flag As Boolean, Optional ByRef vAnalyser_Flag As Boolean, Optional ByRef vAdmin_Flag As Boolean) As Boolean On Error GoTo Err DoCmd.Hourglass True Dim rst As ADODB.Recordset