Please help..getting tooooo complicated

lynsey2

Registered User.
Local time
Today, 10:13
Joined
Jun 18, 2002
Messages
439
Private Sub BaselineMeth_Click()
On Error GoTo Err_BaselineMeth_Click

Dim stDocName As String

stDocName = "baselineMeth Query"
DoCmd.OpenQuery stDocName, acNormal, acEdit


Exit_BaselineMeth_Click:
Exit Sub

Err_BaselineMeth_Click:
Msgbox Err.Description
Resume Exit_BaselineMeth_Click

End Sub


is the code i have in the on click event of a button on a form.

what i want to do though is fill out

Dose mg,
Clear/sugarfree and comments on the form.


so how would i do that???

Private Sub BaselineMeth_Click()
On Error GoTo Err_BaselineMeth_Click

Dim stDocName As String

stDocName = "baselineMeth Query"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Dose_mg = baselineMeth_Query!Dose_mg
if baselineMeth_Query!clearCheck = true then
Clearcheck = true
if baselineMeth_Query!SugarFreeCheck = true then
SugarFreeCheck = true
end if

Exit_BaselineMeth_Click:
Exit Sub

Err_BaselineMeth_Click:
Msgbox Err.Description
Resume Exit_BaselineMeth_Click

End Sub

as you can see i dont do code very well so please excuse the poor attempt but i thought that in theory that would be what i would need to do...run the qry select the fields i need and fill out the fields in the form that match the qry result! and are what i need!
Please help me this is all getting too much if you get this then you might be able to help with my History problem too if you wouldnt mind. i kinda suppose these problems are quite alike. Im not very good at helping people get my problems so if you need a better explanation then just let me know!
thanks in advance!
Lyns:confused: :confused: :( :(
 
I'm Not Sure what you are trying for, so I'm going to try and restate the question.


You have a form with a button.

This form opens a query and returns two values from this query: "Clear" and "SugarFree"

Based on the values of these two Fields from the Query, you set the values of "ClearCheck" and "SugarFreeCheck".


Is this Close?


Instead of using the OpenQuery Method, have you looked into using a "RecordSet Object". This would allow you to open the Query and Retrieve the values that you want.
 
Yup I suppose that’s along the right lines!

I need 3 fields from the result of the qry to fill out the form.

The patient can only have clear or sugar free so

If clearcheck is in the qry result then tick the clearcheck box in the form. If not leave the field in the form blank.

If the sugarfreecheck is in the qry result then tick the sugarfree box in the form. If not leave the field in the form blank.

There will always be a value for Dose mg in the qry result so i want to take this and fill out the field in the form with it.

I would like to click on the button in my form and for these 3 fields to fill out on the screen...don’t want to even see the qry result for this one! Just for the button to run the qry and get the required fields and fill out the fields on the form!

:D

As for RecordSet Object I have never used this and don’t know how it works! It sounds like RecordSet Object could be what I want though so ill look up help but any further assistance on that would be great! As I never seem to have much luck with Access Help.
Thanks so much for replying; I really really really appreciate it! :)

Lyns
 
Hi,
I have an application in which part of the features I have is auto fill, You enter a name or an Id number and related information are used to automatically populate fields on a form. It may not be exactly what you want, but it will give you an idea on how to setup your query and in your code how to code the auto fill feature.

If you want it then e-mail me tayo60@hotmail.com
 

Users who are viewing this thread

Back
Top Bottom