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

Simple If Then statement in using Access in Attachmate

Status
Not open for further replies.

NWildblood

Technical User
Nov 12, 2007
113
GB
Hi, I'm running some jobs from Access in Attachmate, and need a simple VB If ... Then statement to either populate a field or move over it if the field is already populated - what's the easiest syntax to use to determine If the field is already populated ?

Many thanks, not a coder, I just use VB to automate

"No-one got everything done by Friday except Robinson Crusoe...
 
In AccessVBA a simple way is to use the DLookUp function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV - I can't see any examples where my Access VB could be ammended to read fields in Attachmate and populate / skip accordingly. Also not being a coder my ignorance knows no bounds - how would it need to be declared ? And Syntax ?? Any help gratefully received from my non-trained limbo ... ;-)


"No-one got everything done by Friday except Robinson Crusoe...
 
Remou, guys

Thanks, unfortunately I want it to read whether there's data on the Attachmate screen itself, not within the Access DB... have I missed something ...??

"No-one got everything done by Friday except Robinson Crusoe...
 
What is Attachmate ?
How do you use it in Access ?
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This seems to be an Attachmate question and nothing to do with Access. You might have better luck with a forum dedicated to that program.

 
JoeAtWork
Thanks, I've also posted in the Attachmate forum, but it's actually work being run from a VB script in an Access Database.





"No-one got everything done by Friday except Robinson Crusoe...
 
Remou, thanks, here goes; it all works except for the bits where I'm trying to run an If Then statement regarding whether there's any text in field 17, 17, 1.

_____________________
Option Compare Database
________________________
Sub CertifyAndCloseReplacementJobs()



Dim oDB As Database 'ACCESS CODE
Dim oRS As DAO.Recordset 'ACCESS CODE
Dim vSomeVal
Dim System As Object, Sessions As Object, Sess As Object, CSS As Object
Dim msg_line As String ' ? not sure here!


Set System = CreateObject("EXTRA.System") ' Gets the system object

If (System Is Nothing) Then
MsgBox "Could not create the EXTRA System object. Stopping macro playback."
Stop
End If

Set Sessions = System.Sessions

If (Sessions Is Nothing) Then
MsgBox "Could not create the Sessions collection object. Stopping macro playback."
Stop
End If

Set CSS = GetObject("C:\Documents and Settings\zeicri\Desktop\SMNXS06.edp")
Set Sess = System.ActiveSession
Set oDB = OpenDatabase("S:\CommonARUK01\FinAccouUK01\Fixed Asset\SDH\SDH CERTIFICATIONS\CERTIFICATION DATABASE") 'ACCESS CODE
Set oRS = oDB.OpenRecordset("BP INFORMATION") 'ACCESS CODE


If (Sess Is Nothing) Then
MsgBox "Could not create the Session object. Stopping macro playback."
Stop
End If

If Not Sess.Visible Then Sess.Visible = True

msg_line = MyScreen.GetString(17, 17, 1) ' ? not sure here either!



Sess.Screen.SendKeys ("<Home>MLAD<Enter>")
Call Wait(Sess)

If Not oRS.BOF Then
oRS.MoveFirst
Do While Not oRS.EOF

'MLAD HERE:
Sess.Screen.SendKeys ("<Tab>")
Sess.Screen.SendKeys (Trim(oRS.Fields("New Job").Value) & "<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<NewLine><NewLine><NewLine><NewLine><NewLine><NewLine><NewLine>Y<Enter>")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Pf5>")
Call Wait(Sess)
Sess.Screen.SendKeys ("1")
Call Wait(Sess)
Sess.Screen.SendKeys ("<Pf5>")
Call Wait(Sess)

'MFAD HERE: - not sure here

If (msg_line) <> " " Then
Sess.Screen.SendKeys ("<NewLine><NewLine><NewLine>")
Sess.Screen.SendKeys Trim(oRS.Fields("New Job Title").Value) 'TITLE
Sess.Screen.SendKeys ("<Enter>")
Call Wait(Sess)
End If

Sess.Screen.SendKeys ("<Pf15>")
Call Wait(Sess)

'MCLO HERE:


Loop
End If
End Sub
--------------
Private Sub Wait(Sess As Object)
Do While Sess.Screen.OIA.XStatus <> 0
DoEvents
Loop
End Sub



"No-one got everything done by Friday except Robinson Crusoe...
 
This:

msg_line = MyScreen.GetString(17, 17, 1) ' ? not sure here either!

Is not Access. Did you wish to find out if there is data in an Access recordset?
 
Remou
No I'm inputting data to a mainframe - where Attachmate is the front end.

It's part of a wider process managed via a Access DB.

Thanks again.


"No-one got everything done by Friday except Robinson Crusoe...
 
Let me re-phrase that, you will not get help in an Access forum with lines such as :

msg_line = MyScreen.GetString(17, 17, 1) ' ? not sure here either!

Which Access code lines are you having problems with?
 
Hi remou,
Sorry, where I've attempted to dim and marked not sure, and here:



'MFAD HERE: - not sure here

If (msg_line) <> " " Then
Sess.Screen.SendKeys ("<NewLine><NewLine><NewLine>")
Sess.Screen.SendKeys Trim(oRS.Fields("New Job Title").Value) 'TITLE
Sess.Screen.SendKeys ("<Enter>")
Call Wait(Sess)
End If

____
(Bottom line is, it runs the job fine in Attachmate without the If/Then statement)

Thanks again



"No-one got everything done by Friday except Robinson Crusoe...
 
This still goes back to:

msg_line = MyScreen.GetString(17, 17, 1)

Because you are saying:

If (msg_line) <> " " Then

It is quite possible that msg_line is null, in other words, not equal to " ".

You could try :

If Trim(msg_line & "") <> "" Then

You may also wish to examine msg_line:

MsgBox msg_line &
 
Remou
Great, will investigate, thanks for your patience - I am basically trying to reduce an enormous amount of manual transaction processing here on a mainframe using Access VB (and Excel), and have found out all this VB stuff out ad-hoc; appreciate your help.

"No-one got everything done by Friday except Robinson Crusoe...
 
Anyway, what is MyScreen ?
Tip: use the Option explicit instruction.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 




Attachmate is a terminal emulator.

There are two Attachmate forums that I know of...

Forum1

Forum99

Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top