Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2005, 11:36 AM
Authorized User
 
Join Date: Aug 2004
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default ACTIVEDATASHEET PROBLEM [SOLVED]

I am trying to use ActiveDatasheet in VBA code to access the default form that comes from doubleclicking a table name. The code to run from a button will eventually open a text file that acted as the imported data source - the filename is in one of the fields.

The problem is that my code correctly gets the record number from the data form, but returns the field contents of some other record - not the selected one. I do not really want to set up a special form to do this because it means that it will have to be running already.

The code contains 2 methods that I have tried. This one always refers to the field in record 1. The other one goes to some other record.

Any help appreciated. eg. Is there another way I can get the record contents from the record number ?

Code:
Option Compare Database
Option Explicit

Function get_file()
Dim rst As Recordset
Dim recno As Long
Dim Proj As String
'------------------
    Set rst = CurrentDb.OpenRecordset("CSV_LOG")
    recno = Screen.ActiveDatasheet.CurrentRecord
    '---------------------------------------------
    '- version 1
    rst.Move 0
    '---------------------------------------------
    '- version 2
    'rst.MoveLast
    'rst.MoveFirst
    'rst.Move recno
    '---------------------------------------------
    Proj = rst.Fields("CSV_file")
    MsgBox ("CurrentRecord = " & recno & vbCr & Proj)
    rst.Close

End Function
-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.
__________________
-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.
 
Old January 26th, 2005, 05:07 AM
Authorized User
 
Join Date: Aug 2004
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

for the record :-
Code:
    Dim FileName As String
    FileName = Screen.ActiveDatasheet!csv_file
-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem solved bhavna .NET Framework 1.x 1 March 7th, 2007 12:20 PM
I myself solved my problem(now u all pls help me i rashmipant BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 October 12th, 2006 04:34 AM
Problem Solved. blackdevil1979 Beginning VB 6 0 March 22nd, 2005 09:55 PM
ThePhileVB set up problem solved ..But eureka BOOK: ASP.NET Website Programming Problem-Design-Solution 2 August 26th, 2004 06:33 AM
Math problem solved in Java! freezotic BOOK: Beginning Java 2 7 January 21st, 2004 03:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.