Can you combine 3 records into 1 record
my sample data looks like this
1.11.1 this is a test
trying to combine 3
records into 1
2.22.2 based on the numbers
pattern to use as the beginning
of each 1 to 3 records
3.33.3 This 1 record
is to make sure it does
not matter how many records 3 records
are combined to make the 1 record even with
4 records combined
4.44.40 this is 1 record with only
2 records to combine into one
what I need is it to look like
1.11.1 this is a test trying to combine 3 records into 1
2.22.2 based on the numbers pattern to use as the beginning of each 1 to 3 records
3.33.3 This 1 record is to make sure it does not matter how many records 3 records are combined to make the 1 record even with 4 records combined
4.44.40 this is 1 record with only 2 records to combine into one
I know this may be something elaborate in vba in access based on the number pattern when found to end a start a new record.
I will need to do this frequently the number pattern will be the only constant.
macky
Anwsers to the Problem Can you combine 3 records into 1 record
Let's say your table is named tblIn with a field named TextField.
I'll assume that it also has a primary key field named ID that defines the sort order of the records.
Create a new table tblOut with a memo field MemoField (if you are absolutely sure that the combined values will never exceed 255 characters in length, it could be a text field).
Activate the Visual Basic Editor (Alt+F11), insert a new module (Insert | Module), and copy the following code into the module:
Sub CombineRecords()
Dim dbs As DAO.Database
Dim rstIn As DAO.Recordset
Dim fldIn As DAO.Field
Dim rstOut As DAO.Recordset
Dim fldOut As DAO.Field
Dim strOut As String
' Current database
Set dbs = CurrentDb
' Clear target table
dbs.Execute "DELETE * FROM tblOut", dbFailOnError
' Open recordset on source table
Set rstIn = dbs.OpenRecordset("SELECT TextField FROM tblIn ORDER BY ID", _
dbOpenForwardOnly)
' Source field
Set fldIn = rstIn.Fields("TextField")
' Open recordset on target table
Set rstOut = dbs.OpenRecordset("tblOut", dbOpenDynaset)
' Target field
Set fldOut = rstOut.Fields("MemoField")
' Loop through records of source table
Do While Not rstIn.EOF
If fldIn Like "#.#*" Or fldIn Like "##.#*" Then
' Do we have an output value?
If strOut <> "" Then
rstOut.AddNew
fldOut = Trim(strOut)
rstOut.Update
End If
' Start new output value
strOut = ""
End If
strOut = strOut & " " & fldIn
' On to the next record
rstIn.MoveNext
Loop
' Process the remaining string
If strOut <> "" Then
rstOut.AddNew
fldOut = Trim(strOut)
rstOut.Update
End If
' Clean up
rstOut.Close
Set rstOut = Nothing
rstIn.Close
Set rstIn = Nothing
Set dbs = Nothing
End Sub
Substitute the correct names for the tables and fields.
With the insertion point anywhere in the code, press F5 to run it.
Check if there are memory problems
Memory management issues can also cause a BSOD in Windows 7. Thankfully, Windows 7 has a Memory Management Diagnostic tool that detects and solves problems related to system memory.
- Click on the Start button on the Taskbar.
- Type "Windows Memory Diagnostic Tool" or "Memory" (without quotes) in the Search box or,
- Click on Windows Memory Diagnostic Tool (in the search results).
- Click on "Restart now and check for problems (Recommended)".
- The system will restart, and you need to follow the instructions given on the screen.
Another Safe way to Repair the Problem: Can you combine 3 records into 1 record:
How to Fix Can you combine 3 records into 1 record with SmartPCFixer?
1. You can Download SmartPCFixer here. Install it on your system. When you open SmartPCFixer, it will perform a scan.
2. After the scan is done, you can see the errors and problems need to be fixed. Click Fix All.
3. The Fixing part is finished, the speed of your computer will be much higher than before and the errors have been fixed.
Related: How to Download Toshiba Satellite A205-S5833 Supervisor Password Utility v.1.48.0.8C r2 driver,How to Download Toshiba Satellite C675-S7104 Laptop Checkup v.2.0.13.11 driver,How Can I Update & Download Toshiba Satellite L655-S5117 Face Recognition v.3.1.3 driver,Method to Update & Download Toshiba Satellite L845D-SP4328KL Atheros LAN Driver v.2.1.0.5,How to Update & Download Toshiba Satellite R930 Network Device ID Registry Setting Tool v.3.0.32.4 driver,Best Way to Download NVidia GeForce 6100 VGA Driver v.304.51 Certified,How Can You Update & Download NVidia GeForce 9300/nForce 730i VGA Driver v.310.19 Certified,Method to Download NVidia GeForce GT 330M Driver v.340.65,How Can I Update & Download NVidia GeForce GTX 590 Driver v.280.26 WHQL,Method to Download NVidia Tesla C2050 Driver v.319.17,Way to Download RealTek RTL8100C(L) Driver v.5.01,Way to Download RealTek RTL8100E Drivers v.694,Way to Update & Download RealTek RTL8101L Auto Installation Program v.6.110 driver,Method to Update & Download RealTek RTL8111G PXE and RPL ROM code v.2.58 driver,How to Update & Download RealTek RTL8411B(N) Driver v.10.003,Best Way to Update & Download ASUS A53SV nVidia Graphics Driver v.8.17.12.6686,Method to Herunterladen ASUS K75VJ Intel Rapid Storage Technology Treiber v.11.6.0.1030,How Can You Update & Download ASUS CG8580 Intel Chipset Driver v.9.3.0.1019,Method to Update & Download ASUS K41VD Intel INF Update Driver v.9.1.1.1015,Way to Update & Download ASUS Pro70T NB Probe v.3.0.0026 driver
Read More: Troubleshooter of Error: Can I save a large .xlsm file as a binary (.xlsb) file without losing any functionality?,Tech Support: can I review when my computer has been accessed from outside my home?,can I retrieve an excel spreadsheet closed accidentally? [Anwsered],Troubleshooter of Error: can i upgrade visual studio 2008 after installing sp1?,Solution to Problem: can't disply two pdfs at the same time,Can I safely remove earlier versions on my pc,Can I rotate a graph so it shows on my page sideways?,Can I safely ignore Office file validation alert message?,Can I send a JPEG file in a PDF form ?,can I review when my computer has been accessed from outside my home?
No comments:
Post a Comment