Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / September 2005

Tip: Looking for answers? Try searching our database.

VB Help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David M - 16 Sep 2005 11:12 GMT
I have a table imported from a text file.
The format of the file has a record that relates to rows below it. but is
not shown against all lines
In excell I use the following

Record is in column A- output to column B
In colum B I would use the following-=If(a2="",B1,A2)- This then puts the
record against all lines- until it gets to a new record- and acts on that then

Can someone tell me the VB coding required to do this function in access
Ofer - 16 Sep 2005 13:46 GMT
You can create a query that return the desire field

Select A1,B1,IIF(A1="" Or A1 is null,B1,A1) as C1 From TableName

C1 is the field that return the desire value

Signature

I hope that helped
Good luck

> I have a table imported from a text file.
> The format of the file has a record that relates to rows below it. but is
[quoted text clipped - 6 lines]
>
> Can someone tell me the VB coding required to do this function in access
David M - 16 Sep 2005 15:01 GMT
THanks for that
That formula only returns a value from the same line- I need the formula /
VB code to direct to the line above if the condition is not met- i.e if a2 is
null goto a1 else a2

Thanks for you help anyway

David

> You can create a query that return the desire field
>
[quoted text clipped - 12 lines]
> >
> > Can someone tell me the VB coding required to do this function in access
SteveS - 16 Sep 2005 20:48 GMT
> THanks for that
> That formula only returns a value from the same line- I need the formula /
[quoted text clipped - 21 lines]
>>>
>>>Can someone tell me the VB coding required to do this function in access

David,

There is no "above" in a table. There is no guarantee that the order will
remain the same.

This is how I would do it.

Make a copy of the table and name it "tblTemp".
Add a new field named "lngOrder" (type number - long)

Now you have a table (tblTemp) with three fields - Field_A, Field_B and lngOrder.

In a Sub, create varA string, varB string, Kount as integer.
(Note: change varA & varB to the proper type.)

Create a recordset, based on tblTemp.

Open the text file and read the first line.
Parse the line (to varA & varB), add a new record, use 1 for the lngOrder field.

Save the value (Field_B?) to a variable - varNewValue.
Kount = 2

Loop thru the text file,
   read line from text file
   parse line
   check if isnull(varA) then use varNewValue
   add new record
   if isnull(varA) then varNewValue= varB
   'Increment counter
   Kount = kount+1
Until text file EOF

do cleanup

Then run an Append query to append Field_A and Field_B to the Main table.

It would be easier to answer knowing the field names and having an example of
the data, but this should get you moving in the right direction.

HTH
Signature

Steve
--------------------------------
"Veni, Vidi, Velcro"
(I came, I saw, I stuck around.)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.