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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code isn't recognizing my table/field.... 1

Status
Not open for further replies.

chanman525

IS-IT--Management
Oct 7, 2003
169
US
My code....


Function import()
On Error GoTo import_Err


Dim receive As Database
Dim add_date As Field
Dim input_date As TableDef
Dim rec As Recordset
Dim path As String
Dim file_name As String
Dim import_filename As String
Dim month As String
Dim strFileExists As String
Dim year As String
Dim currentmonth As String
Dim Imported As Field
Dim strdate As String



Set receive = CurrentDb()
Set rec = receive.OpenRecordset("input_date")

path = "g:\prorep\tranhist\Receive\"


file_name = (rec!add_date & ".txt")
import_filename = path & file_name

strFileExists = dir(import_filename)
If strFileExists <> "" Then

year = Left$(file_name, 4)
month = Mid$(file_name, 5, 2)
currentmonth = year & month

strdate = Left(importdate!Imported, 4) & "-" & Mid(importdate!Imported, 5, 2) & "-" & Right(importdate!Imported, 2)

If Not IsDate(strdate) Then
Quit acQuitSaveAll

Else

import_filename = path & file_name
DoCmd.TransferText acImportDelim, "receive spec", currentmonth, import_filename, False, ""

End If



The issue I am having is with the line that starts strdate=...


The error comes up and says "variable not defined". Import date is a table and Imported is a text box displaying dates that have been imported.

The field shows dates in this structure...yyyymmdd

Can someone show me what I'm doing wrong?


Basically, I want to say, "If the date exists in the Imported field of the importdate table, then do not import.

Else,
import the date that I entered in the input_date field.

Thanks for the help guys.
 
chanman525,
Depends on what [tt]importdate[/tt] is supposed to point to, and where your code has been placed.

Since I can't tell from the snippet or narrative, here are a couple of thoughts:
[ol][li]If [tt]importdate[/tt] is a form you might try: [tt]Forms!importdate!...[/tt][/li][li]If the code is in a form named [tt]importdate[/tt] you might try [tt]Me.Imported[/tt].[/li][/ol]

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
chanman, as Caution said if it is an open form but, you said "Table".
Then try DLookUp()

If IsNull(DLookUp("Imported","ImportDate")) Then
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top