1

Topic: Help with the code

There is a heap of everything, but here a piece in which it is necessary to take from the second table given corresponding to the data of the first table

' programming Sheet
Dim rsLP As Recordset, myLP, S1 As String
Set rsLP = CurrentDb. OpenRecordset ("select * from [Equipment ] where the Name =" and Me._) ' this line swears
Do Until rsLP.EOF
myLP1 = rsLP! Loops
myLP2 = rsLP! Resistance
rsLP.MoveNext
Loop
_ = "Shlejf-1 =" and asl1 and ", Shlejf-2 =" and asl2 and ", Shlejf-3 =" and asl3 and ", Shlejf-4 =" and asl4 and ", Shlejf-5 =" and asl5 and ", Shlejf-6 =" and asl6 and ", Shlejf-7 =" and asl7 and ", Shlejf-8 =" and asl8 and ", Loops -" and myLP1 and ", Soprot -" and myLP2

P.S.: the data in the field "Name" and "_" the equal
In advance thanks.

2

Re: Help with the code

And what for to you a cycle if in variables myLP1, myLP2 there will be only data of casual record?

3

Re: Help with the code

Wawan2005 wrote:

There is a heap of everything, but here a piece in which it is necessary to take from the second table given corresponding to the data of the first table

Probably you wanted to generate

Dim rsLP As dao. Recordset
dim myLP1, myLP2, S1
s1 = "select * from [Equipment ] where the Name =" and Me._)
debug.print s1 ' "'' check up that have in the Name = and Me._
Set rsLP = CurrentDb. OpenRecordset (s1)
s1 = "Shlejf-1 =" and asl1 and ", Shlejf-2 =" both asl2 and _
& ", Shlejf-3 =" and asl3 and ", Shlejf-4 =" and asl4 and ", Shlejf-5 =" and asl5 _
& ", Shlejf-6 =" and asl6 and ", Shlejf-7 =" and asl7 and ", Shlejf-8 =" and asl8
Do Until rsLP.EOF
myLP1 = rsLP! Loops
myLP2 = rsLP! Resistance
s1=s1 And ", Loops -" and myLP1 and ", Soprot -" and myLP2
rsLP.MoveNext
Loop
_=s1

4

Re: Help with the code

Wawan2005 wrote:

There is a heap of everything, but here a piece in which it is necessary to take from the second table given corresponding to the data of the first table

' programming Sheet
Dim rsLP As Recordset, myLP, S1 As String
Set rsLP = CurrentDb. OpenRecordset ("select * from [Equipment ] where the Name =" and Me._) ' this line swears
Do Until rsLP.EOF
myLP1 = rsLP! Loops
myLP2 = rsLP! Resistance
rsLP.MoveNext
Loop
_ = "Shlejf-1 =" and asl1 and ", Shlejf-2 =" and asl2 and ", Shlejf-3 =" and asl3 and ", Shlejf-4 =" and asl4 and ", Shlejf-5 =" and asl5 and ", Shlejf-6 =" and asl6 and ", Shlejf-7 =" and asl7 and ", Shlejf-8 =" and asl8 and ", Loops -" and myLP1 and ", Soprot -" and myLP2

P.S.: the data in the field "Name" and "_" the equal
In advance thanks.

At you Me._ character value, and character values should consist in apostrophes. For example

Set rsLP = CurrentDb. OpenRecordset ("select * from [Equipment ] where the Name = '" both Me._ and "'")

5

Re: Help with the code

All thanks, I solved a problem on another

' programming Sheet
Dim rsLP As Recordset, myLP, S1 As String
Set rsLP = CurrentDb. OpenRecordset ("select * from [Equipment ]")
Do Until rsLP.EOF
Select Case Me._
Case Is = rsLP! The name
myLP1 = rsLP! Loops
myLP2 = rsLP! Resistance
End Select
rsLP.MoveNext
Loop
_ = "Loops-" and myLP1 and ", Soprot -" and myLP2 ' not necessary I threw out.

Can to whom it is useful.

6

Re: Help with the code

Wawan2005 wrote:

Can to whom it is useful.

At me one sensation, what Vavan, permanently makes changes to the compiler ?...
- That it in the working code has new properties of control items of type Visibl
- Now here abrupt variable declaration myLP, the giving right of use probably child variables myLP1 and myLP2
Or it simply acute shortage Option Explicit?
smile))

7

Re: Help with the code

Wawan2005;
In my opinion you solved the task the most ineffective method which only can be invented. At the size of the table in ten thousand records  to wait very long instead of the tenth fractions of a second. What for here Select Case when it is better If approaches? Is in Case too it is not necessary to use at equality.  it is closed. Well and Option Explicit include, problems will not be gathered.
So will work much faster:

Dim rsLP As Recordset
Set rsLP = CurrentDb. OpenRecordset ("select * from [Equipment ] where [the Name] = '" both Me._ and "'")
With rsLP
If rsLP.Recordcount> 0 Then
_ = "Loops-" and! Loops and ", Soprot -" and! Resistance
Else
_ = "There is no data for the equipment '" both Me._ and "'"
End If
.Close
End With
Set rsLP = Nothing

8

Re: Help with the code

Yes, and to begin will be more correct so:

Dim rsLP As DAO.Recordset
Dim db as DAO.Database
Set db = CurrentDb
Set rsLP = db. OpenRecordset ("select * from [Equipment ] where [the Name] = '" and Replace (Me._, "'", """) and"'")

Variables of libraries are better for declaring with a library title since the same titles are in other libraries, usage order is defined by declaration order, i.e. it is not known as generally.
Do not use CurrentDb for handling , in  more difficult cases there can be errors since CurrentDb specifies in the instant picture of basis, the variable is recreated at any change of structure of basis and the object created with usage CurrentDb directly can become .
Well and in text SQL at substitution of lines it is necessary  single quotes, differently there will be an error if in a title there will be a quote.

9

Re: Help with the code

MrShin;
Well to your knowledge to me oh as that I created as not strange is far, simple works.
And that is why Case so the pure choice, values of a loop and resistance also is necessary to me at the Name equal _;
In the evening I will try also your variant, all problem that 80 % of operators that you wrote I in a shower not to tea as work and that do, I tear out pieces from ready examples and I try to adjust to the tasks.
But if paint as well as what operators in the given piece do, can I will nonsenses fence less?! (It is desirable as for stupid, though why "as"?!)

10

Re: Help with the code

And what is is specific not clearly? Operator With rsLP is necessary in the core in this case only not to write everywhere rsLP in this unit. It is possible to remove it and everywhere where a method/property begin with a point or exclamation point simply to deliver rsLP:

If rsLP.Recordcount> 0 Then
_ = "Loops-" and rsLP! Loops and ", Soprot -" and rsLP! Resistance
Else
_ = "There is no data"
End If
rsLP.Close

11

Re: Help with the code

MrShin;
As it works here

Dim rsLP As Recordset

12

Re: Help with the code

It is simple the declaration of object Recordset from library DAO. It is necessary for you to familiarize with object model VBA if you ask such questions. Without it sensible it will not be possible to make anything.

13

Re: Help with the code

MrShin;
And references traveling not , and that where did not try to read or it is compressed, or it is not clear.

14

Re: Help with the code

Yes in a help all is. Look, for example, object Recordset, there is properties and methods, in the description examples are often resulted. In a network it is full of examples if absolutely to google laziness, buy or download the book for beginners.