URGENT! Link two field of different forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am making a database about in/out scope server
I have a table which contain all in scope server,
and also a form represent it

then i have another form which allow users to type in their required server
in "required server" field and then i have another field "I/O", which i want
the user click this field, then the field will auto generate "IN" if the
required server is in scope, and generate "OUT" if the required server is out
scope.

Now my code is like this

Private Sub IO_Click()
If Me![Requested Server] = Forms![Detail_of_Server]![Server] Then
Me![IO] = "IN"
Else
Me![IO] = "OUT"
End If
End Sub

however, it only work for first record which store in "Detail of Server"
while other cannot.
I mean i have a list of server in the detail of server,
such as: sh90, rk15, jp45............etc
the above code only can work for sh90, while rk15 and jp45 is not work,
what can i do????????


i have searched the post before,
but i can't find any help~
pls help me~
 
I am making a database about in/out scope server
I have a table which contain all in scope server,
and also a form represent it

then i have another form which allow users to type in their required server
in "required server" field and then i have another field "I/O", which i want
the user click this field, then the field will auto generate "IN" if the
required server is in scope, and generate "OUT" if the required server is out
scope.

Now my code is like this

Private Sub IO_Click()
If Me![Requested Server] = Forms![Detail_of_Server]![Server] Then
Me![IO] = "IN"
Else
Me![IO] = "OUT"
End If
End Sub

You're apparently assuming that you can look in a Form to see if there
is data in a table.

You can't. A Form is JUST A WINDOW. It doesn't contain any data.

If you want to see if the requested server exists in the "in scope
server" table, use DLookUp, and look IN THE TABLE - because that's
where the information is stored!

Private Sub IO_Click()
If IsNull(DLookUp("[Server]", "[NameOfInScopeTable]", "[Server] = '" _
& Me![Requested Server] & "'") Then
Me!IO = "Out"
Else
Me!IO = "In"
End If
End Sub

John W. Vinson[MVP]
 
Thx for help,
but the code u give me has error lei,

is it missing one ")"??
where should i put it??

John Vinson said:
I am making a database about in/out scope server
I have a table which contain all in scope server,
and also a form represent it

then i have another form which allow users to type in their required server
in "required server" field and then i have another field "I/O", which i want
the user click this field, then the field will auto generate "IN" if the
required server is in scope, and generate "OUT" if the required server is out
scope.

Now my code is like this

Private Sub IO_Click()
If Me![Requested Server] = Forms![Detail_of_Server]![Server] Then
Me![IO] = "IN"
Else
Me![IO] = "OUT"
End If
End Sub

You're apparently assuming that you can look in a Form to see if there
is data in a table.

You can't. A Form is JUST A WINDOW. It doesn't contain any data.

If you want to see if the requested server exists in the "in scope
server" table, use DLookUp, and look IN THE TABLE - because that's
where the information is stored!

Private Sub IO_Click()
If IsNull(DLookUp("[Server]", "[NameOfInScopeTable]", "[Server] = '" _
& Me![Requested Server] & "'") Then
Me!IO = "Out"
Else
Me!IO = "In"
End If
End Sub

John W. Vinson[MVP]
 
Thx for help lei,
i can fix out the problem

John Vinson said:
I am making a database about in/out scope server
I have a table which contain all in scope server,
and also a form represent it

then i have another form which allow users to type in their required server
in "required server" field and then i have another field "I/O", which i want
the user click this field, then the field will auto generate "IN" if the
required server is in scope, and generate "OUT" if the required server is out
scope.

Now my code is like this

Private Sub IO_Click()
If Me![Requested Server] = Forms![Detail_of_Server]![Server] Then
Me![IO] = "IN"
Else
Me![IO] = "OUT"
End If
End Sub

You're apparently assuming that you can look in a Form to see if there
is data in a table.

You can't. A Form is JUST A WINDOW. It doesn't contain any data.

If you want to see if the requested server exists in the "in scope
server" table, use DLookUp, and look IN THE TABLE - because that's
where the information is stored!

Private Sub IO_Click()
If IsNull(DLookUp("[Server]", "[NameOfInScopeTable]", "[Server] = '" _
& Me![Requested Server] & "'") Then
Me!IO = "Out"
Else
Me!IO = "In"
End If
End Sub

John W. Vinson[MVP]
 
but the code u give me has error lei,

is it missing one ")"??
where should i put it??

Sorry! After the first ):

Private Sub IO_Click()
If IsNull(DLookUp("[Server]", "[NameOfInScopeTable]", "[Server] = '" _
& Me![Requested Server] & "'")) Then
Me!IO = "Out"
Else
Me!IO = "In"
End If
End Sub

John W. Vinson[MVP]
 
Back
Top