Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, I need to read the value of

Status
Not open for further replies.

Biomechanoids

Programmer
Oct 18, 2002
14
US
Hello,
I need to read the value of a particular field of a current record in form. I think the currentrecord method only gives out the number of the record, so that it will not possible to use this.

I need this to creat a directory with a certain name. For example: If I enter a new customer I can click on a buttom in the form and the macro creats automatically a directory with the name of the customer.

For example: my customer has th name "xxx12". I enter this in the form, press the button and my macro should take the name out of the table and creat the directory with a command like this:



Private Sub Command26_Click()


Dim verbindung As ADODB.Connection
Dim datensatz As New Recordset
Dim verbindungsaktivierung As String
Dim abfrage As String
Dim kontrolle As Integer
Dim rs As DAO.Recordset

'setup of the databaseconnection
Set verbindung = CurrentProject.Connection
verbindungsaktivierung = "SELECT *FROM projectdatabase" 'selects whole table
Set datensatz.ActiveConnection = verbindung
datensatz.Open verbindungsaktivierung, , adOpenForwardOnly, adLockReadOnly, adCmdText

Set rs = valueoffieldclient
MkDir "F:\USER\PROJECT TEAMS\" & rs!client
MkDir "F:\USER\PROJECT TEAMS\" & rs!client & "\spec"
rs.Close
Set rs = Nothing

On Error
MsgBox "A directory has already been created"
End If

End Sub


It would be nice if somebody would give me a hint how to solve this problem.

Greetings
Thomas
 
Save the record in the Event you use to get the info.

DoCmd.RunCommand acCmdSaveRecord.

That should write the value to the Table before you run the rest of the code.

Paul
 
Hmmm, ok, but how can I get the value of a certain field, for example the value of the active (current) row and the second colum?

Greetings

Thomas
 
Sorry, I only read that you wanted to press the button and take the Name out of the Table. Can't you set a variable to the value in the Form

Dim strHolder as String 'if it's text
strHolder = Forms!FormName!TextboxName

Then set the Directory to that

MkDir "F:\USER\PROJECT TEAMS\" & strHolder

Or am I still loosing something in the translation.[wink]

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top