object required

  • Thread starter Thread starter Marty
  • Start date Start date
M

Marty

Hello
I had an earlier post about truncated floating point
numbers and the suggestion to change the number of decimal
points under the regional settings did not work. I think
this new code will work however I'm getting an "object
reqired" error. Can you please take a look at this short
bit of code and tell me where I'm going wrong? Obviously
I'm new at this.

Thank you so very much for all your help!

Marty

Dim FabFileName As String
FabFileName = Forms!frmFaBExportFileName.Text0.Value
If Right(FabFileName, 4) <> ".CSV" Or Right(FabFileName,
4) <> ".csv" Then
FabFileName = FabFileName & ".CSV"
End If

DoCmd.SetWarnings False
DoCmd.OpenQuery "qryCreateFaBSelectMarket", acViewNormal,
acEdit
DoCmd.OpenQuery "qryCreateFaBFile", acViewNormal, acEdit
tblFaBFile!LongitudeX.Format = "##00.00000" '***ERROR
OCCURS HERE*** Object Required
DoCmd.OpenQuery "Query2", acViewNormal, acEdit
DoCmd.TransferText acExportDelim, "NewTblFaBFile Export
Specification", "tblFaBFile", _
FabFileName, True, ""
DoCmd.Close acForm, "frmCreateFaBSelectMarket"
DoCmd.Close acForm, "frmFaBExportFileName"


mcrExportFaBFile_Exit:
Exit Function
 
Marty,
Dim FabFileName As String
FabFileName = Forms!frmFaBExportFileName.Text0.Value
If Right(FabFileName, 4) <> ".CSV" Or Right(FabFileName,
4) <> ".csv" Then
FabFileName = FabFileName & ".CSV"
End If

DoCmd.SetWarnings False
DoCmd.OpenQuery "qryCreateFaBSelectMarket", acViewNormal,
acEdit
DoCmd.OpenQuery "qryCreateFaBFile", acViewNormal, acEdit
tblFaBFile!LongitudeX.Format = "##00.00000" '***ERROR
OCCURS HERE*** Object Required

The OpenQuery command does not return anything to the code, the query
has no connection whatsoever with the VBA code. It simply opens the
query as a datasheet (if it's only a SELECT query) or executes it (if
it's some action query) and that's it. For the latter you see the
changes only if you open the table in the DB window.

Your queries seem to be make table queries and I guess you want to set
some properties for the table fields. Because Format is not a native
DAO property set when the table is created, you must define it
yourself. For this, you have to first define and set a TableDef
variable to the table, then create and append the property with the
CreateProperty and Append methods.

You could try instead to format the field in the make table query
using the Format function.

Best regards
Emilia

Emilia Maxim
PC-SoftwareService, Stuttgart
http://www.maxim-software-service.de
 
Back
Top