Visual Basic

J

James Meridian

I am trying to create a SEARCH function through Visual Basic. The problem is
I don't know how to refer to a column.

Two of my column names have the same name, Printer. So on the Form it is
refered to as Datasheet.Form and Datasheet_1.Form

My Search function works but breaks because I don't know how to refer to
column names that are the same.

strWhere = strWhere & "([Datasheet.Form] Like ""*" & Me.txtSearch & "*"") OR
([Datasheet_1.Form] Like ""*" & Me.txtSearch & "*"") AND"

This is what I have so far. But it does not work when I try the actual
filter.

Any help is appreciated!
 
K

Klatuu

Using Datasheet and Form as names is not a good idea. Form is an Access
reserved word and used as a name can confuse Access. Datasheet is not, but
since it is identifies a view type, it should be avoided. Printer is also a
bad name and how do you have two columns with the same name?
 
J

James Meridian

I created a relationship between two tables who happened to have the same
column name.

How do I refer to them on Visual Basic?

Klatuu said:
Using Datasheet and Form as names is not a good idea. Form is an Access
reserved word and used as a name can confuse Access. Datasheet is not, but
since it is identifies a view type, it should be avoided. Printer is also a
bad name and how do you have two columns with the same name?

--
Dave Hargis, Microsoft Access MVP


James Meridian said:
I am trying to create a SEARCH function through Visual Basic. The problem is
I don't know how to refer to a column.

Two of my column names have the same name, Printer. So on the Form it is
refered to as Datasheet.Form and Datasheet_1.Form

My Search function works but breaks because I don't know how to refer to
column names that are the same.

strWhere = strWhere & "([Datasheet.Form] Like ""*" & Me.txtSearch & "*"") OR
([Datasheet_1.Form] Like ""*" & Me.txtSearch & "*"") AND"

This is what I have so far. But it does not work when I try the actual
filter.

Any help is appreciated!
 
K

Klatuu

Where is the code? In a form module?
Are you trying to refer to field names in a recordset, or controls on a form?
--
Dave Hargis, Microsoft Access MVP


James Meridian said:
I created a relationship between two tables who happened to have the same
column name.

How do I refer to them on Visual Basic?

Klatuu said:
Using Datasheet and Form as names is not a good idea. Form is an Access
reserved word and used as a name can confuse Access. Datasheet is not, but
since it is identifies a view type, it should be avoided. Printer is also a
bad name and how do you have two columns with the same name?

--
Dave Hargis, Microsoft Access MVP


James Meridian said:
I am trying to create a SEARCH function through Visual Basic. The problem is
I don't know how to refer to a column.

Two of my column names have the same name, Printer. So on the Form it is
refered to as Datasheet.Form and Datasheet_1.Form

My Search function works but breaks because I don't know how to refer to
column names that are the same.

strWhere = strWhere & "([Datasheet.Form] Like ""*" & Me.txtSearch & "*"") OR
([Datasheet_1.Form] Like ""*" & Me.txtSearch & "*"") AND"

This is what I have so far. But it does not work when I try the actual
filter.

Any help is appreciated!
 
J

James Meridian

Its a form code that under _Click of my button. It should set the filter to
the strWhere. I just don't know how to refer to the columns that have same
names.

Klatuu said:
Where is the code? In a form module?
Are you trying to refer to field names in a recordset, or controls on a form?
--
Dave Hargis, Microsoft Access MVP


James Meridian said:
I created a relationship between two tables who happened to have the same
column name.

How do I refer to them on Visual Basic?

Klatuu said:
Using Datasheet and Form as names is not a good idea. Form is an Access
reserved word and used as a name can confuse Access. Datasheet is not, but
since it is identifies a view type, it should be avoided. Printer is also a
bad name and how do you have two columns with the same name?

--
Dave Hargis, Microsoft Access MVP


:

I am trying to create a SEARCH function through Visual Basic. The problem is
I don't know how to refer to a column.

Two of my column names have the same name, Printer. So on the Form it is
refered to as Datasheet.Form and Datasheet_1.Form

My Search function works but breaks because I don't know how to refer to
column names that are the same.

strWhere = strWhere & "([Datasheet.Form] Like ""*" & Me.txtSearch & "*"") OR
([Datasheet_1.Form] Like ""*" & Me.txtSearch & "*"") AND"

This is what I have so far. But it does not work when I try the actual
filter.

Any help is appreciated!
 
K

Klatuu

Sorry, James, but I am getting lost in your terminonlgy. What columns?
What are Datasheet.Form and Datasheet_1.Form?

Can you be a bit more specific about what object names you are using and
what kind of object they are?
Typically, when you are creating a filtering string, you use the name of
controls on your form. The reason the word column is confusing me is because
combo and list boxes do have columns, but they don't have different names.
The other context of column would be a field, but you don't normally refer
to the field names in forms. I don't say never, but not normally.
--
Dave Hargis, Microsoft Access MVP


James Meridian said:
Its a form code that under _Click of my button. It should set the filter to
the strWhere. I just don't know how to refer to the columns that have same
names.

Klatuu said:
Where is the code? In a form module?
Are you trying to refer to field names in a recordset, or controls on a form?
--
Dave Hargis, Microsoft Access MVP


James Meridian said:
I created a relationship between two tables who happened to have the same
column name.

How do I refer to them on Visual Basic?

:

Using Datasheet and Form as names is not a good idea. Form is an Access
reserved word and used as a name can confuse Access. Datasheet is not, but
since it is identifies a view type, it should be avoided. Printer is also a
bad name and how do you have two columns with the same name?

--
Dave Hargis, Microsoft Access MVP


:

I am trying to create a SEARCH function through Visual Basic. The problem is
I don't know how to refer to a column.

Two of my column names have the same name, Printer. So on the Form it is
refered to as Datasheet.Form and Datasheet_1.Form

My Search function works but breaks because I don't know how to refer to
column names that are the same.

strWhere = strWhere & "([Datasheet.Form] Like ""*" & Me.txtSearch & "*"") OR
([Datasheet_1.Form] Like ""*" & Me.txtSearch & "*"") AND"

This is what I have so far. But it does not work when I try the actual
filter.

Any help is appreciated!
 
J

James Meridian

The Form I am creating has a Record Source to another table. In that table
has the columns or fields Datasheet.Form and Datasheet_1.Form. The reason it
has this is because I've created a relationship within itself. The problem
that I am having is when I am trying to refer to one of these fields in
Visual Basic I don't know what to call them on.

I hope this makes sense.

Klatuu said:
Sorry, James, but I am getting lost in your terminonlgy. What columns?
What are Datasheet.Form and Datasheet_1.Form?

Can you be a bit more specific about what object names you are using and
what kind of object they are?
Typically, when you are creating a filtering string, you use the name of
controls on your form. The reason the word column is confusing me is because
combo and list boxes do have columns, but they don't have different names.
The other context of column would be a field, but you don't normally refer
to the field names in forms. I don't say never, but not normally.
--
Dave Hargis, Microsoft Access MVP


James Meridian said:
Its a form code that under _Click of my button. It should set the filter to
the strWhere. I just don't know how to refer to the columns that have same
names.

Klatuu said:
Where is the code? In a form module?
Are you trying to refer to field names in a recordset, or controls on a form?
--
Dave Hargis, Microsoft Access MVP


:

I created a relationship between two tables who happened to have the same
column name.

How do I refer to them on Visual Basic?

:

Using Datasheet and Form as names is not a good idea. Form is an Access
reserved word and used as a name can confuse Access. Datasheet is not, but
since it is identifies a view type, it should be avoided. Printer is also a
bad name and how do you have two columns with the same name?

--
Dave Hargis, Microsoft Access MVP


:

I am trying to create a SEARCH function through Visual Basic. The problem is
I don't know how to refer to a column.

Two of my column names have the same name, Printer. So on the Form it is
refered to as Datasheet.Form and Datasheet_1.Form

My Search function works but breaks because I don't know how to refer to
column names that are the same.

strWhere = strWhere & "([Datasheet.Form] Like ""*" & Me.txtSearch & "*"") OR
([Datasheet_1.Form] Like ""*" & Me.txtSearch & "*"") AND"

This is what I have so far. But it does not work when I try the actual
filter.

Any help is appreciated!
 
L

Larry Linson

What is "Datasheet"? Is that the name of a Table? Or, are you under the
impression that Datasheet will refer to the RecordSource of a Form displayed
in datasheet view?

At best, your choices of the names of Access objects for objects of your own
creation is confusing to us mere humans; at worst, you are going to be
astonished when Access interprets correctly what you've coded and you find
that it is not what you desired.

Larry Linson
Microsoft Office Access MVP

James Meridian said:
The Form I am creating has a Record Source to another table. In that table
has the columns or fields Datasheet.Form and Datasheet_1.Form. The reason
it
has this is because I've created a relationship within itself. The problem
that I am having is when I am trying to refer to one of these fields in
Visual Basic I don't know what to call them on.

I hope this makes sense.

Klatuu said:
Sorry, James, but I am getting lost in your terminonlgy. What columns?
What are Datasheet.Form and Datasheet_1.Form?

Can you be a bit more specific about what object names you are using and
what kind of object they are?
Typically, when you are creating a filtering string, you use the name of
controls on your form. The reason the word column is confusing me is
because
combo and list boxes do have columns, but they don't have different
names.
The other context of column would be a field, but you don't normally
refer
to the field names in forms. I don't say never, but not normally.
--
Dave Hargis, Microsoft Access MVP


James Meridian said:
Its a form code that under _Click of my button. It should set the
filter to
the strWhere. I just don't know how to refer to the columns that have
same
names.

:

Where is the code? In a form module?
Are you trying to refer to field names in a recordset, or controls on
a form?
--
Dave Hargis, Microsoft Access MVP


:

I created a relationship between two tables who happened to have
the same
column name.

How do I refer to them on Visual Basic?

:

Using Datasheet and Form as names is not a good idea. Form is an
Access
reserved word and used as a name can confuse Access. Datasheet
is not, but
since it is identifies a view type, it should be avoided.
Printer is also a
bad name and how do you have two columns with the same name?

--
Dave Hargis, Microsoft Access MVP


:

I am trying to create a SEARCH function through Visual Basic.
The problem is
I don't know how to refer to a column.

Two of my column names have the same name, Printer. So on the
Form it is
refered to as Datasheet.Form and Datasheet_1.Form

My Search function works but breaks because I don't know how to
refer to
column names that are the same.

strWhere = strWhere & "([Datasheet.Form] Like ""*" &
Me.txtSearch & "*"") OR
([Datasheet_1.Form] Like ""*" & Me.txtSearch & "*"") AND"

This is what I have so far. But it does not work when I try the
actual
filter.

Any help is appreciated!
 
K

Klatuu

Sorry, James. It is still not making any sense to me.
A recordset or form record source cannot have two fields (columns) with the
same name. Additionally, there are times when you refere to a field name in
a form's recordset, but usually, you refer to the name of the control the
field is bound to.

I really would like to help, but your description is so ambigious, I don't
even know what objects you are talking about. Perhaps if you tell me the
name of the form, the name of the fields in the form's record source, and the
name of the control each field is bound to, I might be able to help.
--
Dave Hargis, Microsoft Access MVP


James Meridian said:
The Form I am creating has a Record Source to another table. In that table
has the columns or fields Datasheet.Form and Datasheet_1.Form. The reason it
has this is because I've created a relationship within itself. The problem
that I am having is when I am trying to refer to one of these fields in
Visual Basic I don't know what to call them on.

I hope this makes sense.

Klatuu said:
Sorry, James, but I am getting lost in your terminonlgy. What columns?
What are Datasheet.Form and Datasheet_1.Form?

Can you be a bit more specific about what object names you are using and
what kind of object they are?
Typically, when you are creating a filtering string, you use the name of
controls on your form. The reason the word column is confusing me is because
combo and list boxes do have columns, but they don't have different names.
The other context of column would be a field, but you don't normally refer
to the field names in forms. I don't say never, but not normally.
--
Dave Hargis, Microsoft Access MVP


James Meridian said:
Its a form code that under _Click of my button. It should set the filter to
the strWhere. I just don't know how to refer to the columns that have same
names.

:

Where is the code? In a form module?
Are you trying to refer to field names in a recordset, or controls on a form?
--
Dave Hargis, Microsoft Access MVP


:

I created a relationship between two tables who happened to have the same
column name.

How do I refer to them on Visual Basic?

:

Using Datasheet and Form as names is not a good idea. Form is an Access
reserved word and used as a name can confuse Access. Datasheet is not, but
since it is identifies a view type, it should be avoided. Printer is also a
bad name and how do you have two columns with the same name?

--
Dave Hargis, Microsoft Access MVP


:

I am trying to create a SEARCH function through Visual Basic. The problem is
I don't know how to refer to a column.

Two of my column names have the same name, Printer. So on the Form it is
refered to as Datasheet.Form and Datasheet_1.Form

My Search function works but breaks because I don't know how to refer to
column names that are the same.

strWhere = strWhere & "([Datasheet.Form] Like ""*" & Me.txtSearch & "*"") OR
([Datasheet_1.Form] Like ""*" & Me.txtSearch & "*"") AND"

This is what I have so far. But it does not work when I try the actual
filter.

Any help is appreciated!
 

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