There are several pieces of data that need to be extracted from the text file. I like the idea of reading the entire file into a table, then manipulating the data.
Thanks to all of you that took the time to respond. Much appreciated!
We are trying to import a text file. We are having two problems.
First a little history about the text file:
The text file contains results of a lab test. The data of interest does not appear before row 50 of the text file. The text import wizard in access does not show any rows after row 25...
No Single quotes - Doesn't work
Here is the code as edited to remove single quotes:
Set rst = dbs.OpenRecordset("Select " & strTest & " from Custody where LABID = '" & Me.txtLabID & "' AND " & strTest & " = '" & Me.txtMethod & "';")
If I knew how to make the value appear in a MsgBox, I...
Hi PB,
Here is the line of code after editing.
Set rst = dbs.OpenRecordset("Select '" & strTest & "' from Custody where LABID = '" & Me.txtLabID & "' AND '" & strTest & "' = '" & Me.txtMethod & "';")
If I take the existing select line and put it in a MsgBox, the only part that is evaluated showing quotes are the form references.
Just for kicks, I edited the line so that the variable was treated the same way as the from references - didn't help. The form references show the values in the form...
I am trying to use the variable strTest as a variable in the select statement below.
The fields in the custody database contain F8 thru F34.
Private Sub txtMethod_BeforeUpdate(Cancel As Integer)
strA = 8
Do While strA < 35
strTest = "F" + strA
Set dbs = CurrentDb
Set rst =...
How can one pass a variable form form code to macro code.
StrA is a variable with the value of 8 used in the vba code of a form - frmCustody
We have a macro called Test
how can macro test run the line:
MsgBox strA
and have the value 8 appear in the message box.
Thanks,
B
I have written the following macro that is in module 1.
Sub Test()
DoCmd.SelectObject acForm, "frmCustody"
frmCustody.Me.Controls("F9").Value = "Ag"
End Sub
I get the following error: Object required.
Any ideas how to get the value to show up in the form when the macro runs??
Thanks,
B
Simplest Solution
Set rst = dbs.OpenRecordset("SELECT LocationName FROM PWS WHERE LocationNumber='" & Me.LocationNumber & "' AND PWSName='" & Me.PWSName & "';")
Thanks to all for your help.
The code above works, and is easiest for me to grasp.
Thanks again to all!!
Punctuation Problems
Location number is actually a text field - there are some characters in a few of the location numbers.
If you look at the first line of code - it works.
In the second line I am trying to select based on two criteria:
the location number AND the location name - both text...
It took forever to get the following line to work in VBA:
Set rst = dbs.OpenRecordset("Select [LocationName] from PWS where [LocationNumber] = '" & Me.LocationNumber & "';")
Now I am trying to get the following line of code to run with no success:
Set rst = dbs.OpenRecordset("Select...
Concatenation Thank you
Hi Bob,
Thanks for the reply. I can't wait to get home and give it a shot. I have a feeling that the snippet you sent will do the job.
Thanks again.
BB
Concat cont'd
We are an environmental testing lab.
We enter samples into a table called Custody using a form - frmCustody.
The form has more than 20 text boxes. Each text box is from a field in the Custody table.
The form has text boxes F8 thru F28.
When using the form we enter lab tests...
Correction to previous reply
Private Sub cmdContinue_Click()
strA = "8"
Do While "Me.F" & strA <> ""
MsgBox "Me.F" & strA
strA= strA +1
End
The MsgBox displays Me.F8 not A
thanks