export table and give it a name from the value in another unbound table

N

niksto

In a form I have a button called myexport
and the code You see below.

I want to export this table (myaccesstable) giving it a name that identifies
it
including in my filename one singel
value from another table, "theothertable" that only contains one singel
value.

theothertable
myvalue 3
(this tableonly contains one value and one row)

Private Sub myexport _Click()
Dim str As String
Dim mydate As Date
mydate = Date
str = "mycreatedfile.xls"
DoCmd.OutputTo acOutputTable, "myaccesstable", acFormatXLS, "D:\" & mydate &
str, True
'I want to include myvalue, that here is 3 like this;
'DoCmd.OutputTo acOutputTable, "myaccesstable", acFormatXLS, "D:\" myvalue &
mydate & str, True
End Sub
 
G

Guest

Use a DLookup to get the value in the other table into a variable
Like : Dim varTmp as varian
varTmp = DLookup("myValue","theothertable"
Then just use the variable
if not isNull(varTmp) the
DoCmd.OutputTo acOutputTable, "myaccesstable", acFormatXLS, "D:\" & varTmp
mydate & str, Tru
els
'You need to find out why it is Nul
end i


----- niksto wrote: ----

In a form I have a button called myexpor
and the code You see below

I want to export this table (myaccesstable) giving it a name that identifie
i
including in my filename one singe
value from another table, "theothertable" that only contains one singe
value

theothertabl
myvalue
(this tableonly contains one value and one row

Private Sub myexport _Click(
Dim str As Strin
Dim mydate As Dat
mydate = Dat
str = "mycreatedfile.xls
DoCmd.OutputTo acOutputTable, "myaccesstable", acFormatXLS, "D:\" & mydate
str, Tru
'I want to include myvalue, that here is 3 like this
'DoCmd.OutputTo acOutputTable, "myaccesstable", acFormatXLS, "D:\" myvalue
mydate & str, Tru
End Su
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top