UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Macro To Use Same Field Information On Next Record, Office 2007    
 
   
razno
post Apr 10 2012, 04:34 AM
Post #1

UtterAccess Addict
Posts: 129



This is stupid questions, but i ma trying to find answer.

I would like combobox value to be same (what user chosed) after user save record and go to new one.
So user sellect exam ID let say 4 and enter a lot new records with students who will participate in exam 4.


And second question:

when user select in that combobox exam ID (let say 4) - i would like to make that data sheet below show only exam 4 students.
So, basicly if entered any value in form ID, i would like split form to show filtered result exam 4 result only.


Sorry for my english...

Thanks you
Go to the top of the page
 
+
arnelgp
post Apr 10 2012, 06:19 AM
Post #2

UtterAccess Ruler
Posts: 1,090



You fill up the Link Master Fields / Link Child Fields (Property Sheet => Data) of your datasheet.

Link Master Fields : yourComboboxName
Link Child Fields: yourSubform ID field name
Go to the top of the page
 
+
BruceM
post Apr 10 2012, 06:26 AM
Post #3

UtterAccess VIP
Posts: 2,452
From: Downeast Maine



QUOTE
I would like combobox value to be same (what user chosed) after user save record and go to new one.

You should be able to use the After Update event of the control bound to the date field to set the Default Value for new records. If that control is named txtExamDate, in its After Update event:

Me.txtExamDate.DefaultValue = Me.txtExamDate

QUOTE
So, basicly if entered any value in form ID, i would like split form to show filtered result exam 4 result only.


If you mean there is a form and subform, the Link Child and Link Master properties of the subform control (the "box" on the main form that contains the subform) should be set to the linking field between the main form's table and the subform's table. You haven't described the structure, but generally speaking, you would have a form for Exams, another for Students, and a junction table for StudentExam (or whatever you would like to call it).

CODE
tblExam
  ExamID (autonumber primary key, or PK)
  ExamNumber
  ExamDate
  etc.

tblStudent
  StudentID (PK)
  FirstName
  LastName
  etc.

tblExamStudent
  ExamStudentID (PK)
  ExamID (link to ExamID in tblExam)
  StudentID (link to StudentID in tblStudent)

The main form is based on tblExam, and the subform on tblExamStudent. There would be a separate form for entering Student information. On the subform, a combo box bound to StudentID. The combo box Row Source is a query based on tblStudent, something like:

SELECT [StudentID], [LastName] & ", " & [FirstName] As [FullName] FROM tblStudent ORDER BY [LastName], [FirstName]

The combo box Bound Column is 1, the Column Count is 2, and the Column Widths something like 0;2

This is just a sketch. There may be other tables, such as an ExamList table in which Exam 4 and the rest of the Exams are listed. You would use this list to set the ExamNumber in tblExam (the source for the main form).
Go to the top of the page
 
+
razno
post Apr 11 2012, 05:44 AM
Post #4

UtterAccess Addict
Posts: 129



QUOTE (BruceM @ Apr 10 2012, 12:26 PM) *
You should be able to use the After Update event of the control bound to the date field to set the Default Value for new records. If that control is named txtExamDate, in its After Update event:

Me.txtExamDate.DefaultValue = Me.txtExamDate


Thats it:)




QUOTE (BruceM @ Apr 10 2012, 12:26 PM) *
If you mean there is a form and subform, the Link Child and Link Master properties of the subform control (the "box" on the main form that contains the subform) should be set to the linking field between the main form's table and the subform's table. You haven't described the structure, but generally speaking, you would have a form for Exams, another for Students, and a junction table for StudentExam (or whatever you would like to call it).



Cannot be done in splitform? Somewhere it work (filter result based on input, and somewhere dont).



Thanks you all for helping me (IMG:style_emoticons/default/smile.gif)




Go to the top of the page
 
+
BruceM
post Apr 11 2012, 06:17 AM
Post #5

UtterAccess VIP
Posts: 2,452
From: Downeast Maine



I don't have Access 2007 here , so I can't help with the split form. However, the table structure is the foundation of the database. A split form, as I understand, shows two views of the same data, so if the filter is applied to one form it should be the same recordset in the other form, but I don't know if this is accurate, so I won't say any more about it except to say that as I understand it is another way of presenting data, and not a substitute for proper structure.

This post has been edited by BruceM: Apr 11 2012, 06:21 AM
Go to the top of the page
 
+
razno
post Apr 11 2012, 12:26 PM
Post #6

UtterAccess Addict
Posts: 129



Thanks you very much!:)
Go to the top of the page
 
+
razno
post Apr 17 2012, 04:28 PM
Post #7

UtterAccess Addict
Posts: 129



Sorry for bringing up my old thread.

What is best way to integrate counter in that form?

I have form with combo with exam ID.

That value is linked to subform in datasheet based on query so i get list of student in selected exam.
So, what is best way to show number of student in that exam?

Thanks you

This post has been edited by razno: Apr 17 2012, 04:28 PM
Go to the top of the page
 
+
missinglinq
post Apr 17 2012, 10:00 PM
Post #8

UtterAccess Ruler
Posts: 2,667



QUOTE (razno @ Apr 17 2012, 05:28 PM) *
...What is best way to integrate counter in that form?

...So, what is best way to show number of student in that exam?


To be honest, I'm a little fuzzy as to exactly what you're doing here, but the 'count' can be determined with the DCount() function. I think you've indicated that Bruce's code

CODE
Me.txtExamDate.DefaultValue = Me.txtExamDate


worked for you, which means that the Field being carried forward is defined as a Number or Autonumber Datatype, so something like

CODE
=DCount("*", "TableOrQueryName", "ExamID = " & Me.YourComboboxName)


in the Control Source for the 'counter' Textbox should work.

You notice that I said that your Test ID Field has to be defined as a Number; that's because Bruce's code is only the correct syntax if it is a Number. If you use the same syntax trying to carry forward a Text Field or Date Field using that code it will pop an error. Each type of Field needs its own syntax, unless you use something like this:

CODE
Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"

This code will work regardless of the Datatype involved, Text, Number, Autonumber or DateTime Fields.

Linq ;0)>
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 25th May 2013 - 10:35 AM