clear form fields on the form opening

lynsey2

Registered User.
Local time
Today, 11:25
Joined
Jun 18, 2002
Messages
439
i thought i knew how to do this as i asked a while ago but it doesnt seem to work! and i cant find my post!
i simply want all of my forms to have empty fields when they open up(after another patient has been selected)

i have basically 4 forms

Splash screen

Select patient

Create Meth

Create ART

the splash screen lets you select which of the others to go into,...you kinda need to go into Select patient first though or it gives you jip! but thats what i want!

in select patient you choose a patient from their patient number either by typing it in or by using the combo, this then fills out the other text boxes on the form with things like patient name, address etc. when this is opened it shows the details of the last patient selected, i dont want this i want it blank.

from this form you go to ART say...and the selected patients details are filled out in the art form, i want everything in the art form to be empty except these details. Thens long as you dont select another patient the info you fill in will stay in the form no matter what you do but as soon as you select another patient the art form opens blank

it would be ok if the last details you filled in were there for a selected patient as long as if they didnt want to use those details they could clear the form and start again with a blank one only showing the patient details.

same goes for create meth!:(

sorry again for being a pain.:p ooh that rhymes
 
set the Data Entry property of the forms to Yes, this will make the form open to a blank record.

would subforms not be a better way of linking the other forms?
 
thats the thing it already is set to yes!
thats what i ment when i said i thought i knew how to do it.
:confused: :confused:
i would more than likely be better with subforms but im soooo not good at this and what i have almost works so my best bet is to leave well alone!:rolleyes: im really that bad!!:o

anyway i still didnt solve this clearing the forms thing! with my Data Entry property of the forms set to Yes. im stuck, im not the only one who thought that was how to do it so i do feel better now!:D im not totaly totaly daft! just a wee bit!
 
DoCmd.OpenForm "frmblahblah", , , NewRecord

might work :)
 
i also have that in the on open event of the form! it gives me error messages!:(
my small problems are never so small. what is it with me and access!??it just doesnt like me!
Thanks so much for helping me, i just dont get it.
 
have you tried it in the on load event instead? I created a form yesterday where I wanted a value passed into a field, it didn't work in the on open event but did in the on load.
 
nope that doesnt work either.

well i suppose it kind of does! it brings up the last script for the selected patient, which is OK in fact thats good, but i will need a button that could clear all the feilds so the doc can do another script(if they want a different one) the ref number would also need to change. but the ref number would have to change if the doctor wanted to print the same script again(for like a repeat script)say they created the last one a week ago and they select the patient today, what is showing up is the last script for the patient, if the doc just wants the patient to have the same drugs he/she should just be able to print the same script without filling it out again, but the ref number would have to be the next number from the autonumbers(the other ref numbers) in the table and the dates would have to be changed so that pharmacy would give the patient the drugs.

so say the doc gets the old script up and wants the same again..i wonder if on changing the dates on the script the ref number could be set to update and treat the script as a new one????? and if the doc doesnt want the same script if on clicking a button i could get it to start a new record with the fields blank and a new ref number????

sorry way off on a tangent here just thinking out loud, but i would need help with it anyway but that might solve having to get the forms clear everytime, i would definatly need the new record button though!!! hmmm what do you think do you think that's a good idea?? do you even get what im saying? i wonder if it would be easy enough....well in theory yes but knowing me:rolleyes: let me know if you think that would solve the clearing the forms on them opening problem, any suggestion to what i said would be more than welcome too.

Lyns:D
 
create an 'add new record' button on the form then play around with the code

standard add new record code
Code:
Private Sub AddNew_Click()
On Error GoTo Err_AddNew_Click


    DoCmd.GoToRecord , , acNewRec

Exit_AddNew_Click:
    Exit Sub

Err_AddNew_Click:
    MsgBox Err.Description
    Resume Exit_AddNew_Click
    
End Sub


then experiment with adding code to retain information from the existing record and add to the new record e.g

Code:
Private Sub AddNew_Click()
On Error GoTo Err_AddNew_Click

Dim strField1 As String
Dim strField2 As String

Set strField1 = Forms!frmBlah!Field1
Set strField2 = Forms!frmBlah!Field2

    DoCmd.GoToRecord , , acNewRec

Forms!frmBlah!Field1 = strField1
Forms!frmBlah!Field2 = strField2

Exit_AddNew_Click:
    Exit Sub

Err_AddNew_Click:
    MsgBox Err.Description
    Resume Exit_AddNew_Click
    
End Sub


this is untested but works in theory :)
 
right sor far so good, my add new record button is ok, standard as. I used the wizard for it.

i was going to put code in the after update of the START DATE field, something so it does this:

after START DATE is changed copy the contents of all filled in fields into a new record. Then allow changes.

this would/should automaticaly give me a new ref number!! i will try that just now!
 
I think that this will also change the date for the record that is currently selected
 
yes!
the doc goes in and its last weeks script that is shown.
they want exactly the same script but it has to be for todays date.
so when they change the date from last weeks to todays then copy all the details and put them in a new record!
hence in the after update event of START DATE (cos it will always have to start on a different date)

Private Sub Start_Date_AfterUpdate()
DoCmd.RunCommand acCmdCopyRecord
DoCmd.RunCommand acCmdRecordsGoToNew
DoCmd.RunCommand acCmdPasteRecord
End Sub

this doent work but i suppose this is what i will need to do!

unless i create another Print button and call it print repeat script and make it a create new record button but put the extra code in that one.!!!that sounds better do you think!??
 
right i have gone into the wizard and created a duplicate button i added this code at the top: DoCmd.GoToRecord , , acNewRec
the rest is from the wizard, i get an error message "the command or action 'copy' isnt available now"

Private Sub RepeatARTScript_Click()
On Error GoTo Err_RepeatARTScript_Click

DoCmd.GoToRecord , , acNewRec

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

Exit_RepeatARTScript_Click:
Exit Sub

Err_RepeatARTScript_Click:
Msgbox Err.Description
Resume Exit_RepeatARTScript_Click

End Sub
 
you need to copy before you go to the new record
 
right nope im not getting anywhere! i tried your original idea by putting two new record buttons on, leaving one standard and making the other like you say;

Private Sub repeatARTScript_Click()
On Error GoTo Err_repeatARTScript_Click

Dim pickDrug1 As String
Dim pickForm1 As String

Set pickDrug1 = Forms!ARTScript!pickDrug1
Set pickForm1 = Forms!ARTScript!pickForm1

DoCmd.GoToRecord , , acNewRec

Forms!ARTScript!pickDrug1 = pickDrug1
Forms!ARTScript!pickForm1 = pickForm1

Exit_repeatARTScript_Click:
Exit Sub

Err_repeatARTScript_Click:
Msgbox Err.Description
Resume Exit_repeatARTScript_Click

End Sub

i have only used two fields to test it out first! i get an error message: compile error object required!

told you i was no good trust me to go off on a tangent.
 
change
Dim pickDrug1 As String
Dim pickForm1 As String

Set pickDrug1 = Forms!ARTScript!pickDrug1
Set pickForm1 = Forms!ARTScript!pickForm1

DoCmd.GoToRecord , , acNewRec

Forms!ARTScript!pickDrug1 = pickDrug1
Forms!ARTScript!pickForm1 = pickForm1

to

Dim strpickDrug1 As String
Dim strpickForm1 As String

Set strpickDrug1 = Forms!ARTScript!pickDrug1
Set strpickForm1 = Forms!ARTScript!pickForm1

DoCmd.GoToRecord , , acNewRec

Forms!ARTScript!pickDrug1 = strpickDrug1
Forms!ARTScript!pickForm1 = strpickForm1
 
i think its back to the drawing board for me im afraid, on open have everything blank!all the time!

although that still doesnt work!

thanks for showing/suggesting how to do stuff im not good so i recon i was just trying something a step to much!

THEORY not difficult

put ME and THEORY together and by jolly do you get some weird and wonderful connection to the almost impossable!:D

shoot me now!before i do anymore dammage!:D

p.s please note that the shoot me now part is a JOKE i do not now or ever wish to be shot thank you very much.

TA cheers and thanks again!for your help...any suggestion much much more than welcome! even if it is give up!
 
try this

create a button on the first form, and use this code to make it open the second form to a blank record

DoCmd.OpenForm "frmBlah"
DoCmd.GoToRecord acForm, "frmBlah", acNewRec
 
i already had code i needed in my other buttons so i did what you said but just added
DoCmd.GoToRecord acForm, "frmBlah", acNewRec

that line into my already created button

Private Sub SPARTChoose_Click()
On Error GoTo Err_SPARTChoose_Click
'go to the ART script
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ARTScript"
'use the selected patient and fill their details into ART
'make the form fill the screen
stLinkCriteria = "[Patient Number]=" & Me![Combo43]
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord acForm, "ARTScript", acNewRec
DoCmd.Maximize


Exit_SPARTChoose_Click:
Exit Sub

Err_SPARTChoose_Click:
Msgbox Err.Description
Resume Exit_SPARTChoose_Click

End Sub

guess what it works! thanks a million didnt think to do that! it not my fandangled wee added extra but hey! it clears my forms and thats the original problem.
 
:D :D

:p
you'll not reply yo my posts again anyway! im hard work eh!:D :p
 

Users who are viewing this thread

Back
Top Bottom