1

(7 replies, posted in General)

Nice, I did get it to work with loading the grid by code, but I like your way much better. 4 less lines of code.

2

(7 replies, posted in General)

OK, all issues resolved except for one.

When I open the form that has the doctor grid on it, I don't know how to filter for only doctors that have the userid of the person that's logged in.

I think that's my only issue left...

Is there a magical way to do that or will I have to look at loading the grid via script?? If so, I'll have to track down an example of that.

Thanks
Alan

3

(7 replies, posted in General)

I ended up doing a dbupdate upon opening the form, and so now it loads values into my combobox, however if the record has a value it doesn't show.

Obviously I'm doing something a bit wrong.

I can't attach my project here as it's getting much bigger and more proprietary.

Alan

4

(7 replies, posted in General)

I added the relationship between Doctor and _user and I can get the proper value loaded in the table, however I don't know who to get the Grid when I want to list the doctors for that _user to work properly. If I say show all then it indeed shows all, but that includes other users records.
If I say Show child records (if any, I don't get anything

I could try adding a filter but don't know if there is anyway to add the application.user.id field in the Filter since the filter I believe is actually a sql statement filter.

and then I still have the combobox not loading values when the form starts up. It doesn't show what was loaded into the record also

5

(7 replies, posted in General)

Right now I have the combobox in medications form set to Medication.id_Doctor and DrName for the foreignKey and FieldName.

Do I have to do something special to get the combobox to first load with values?? If I go to my Add Doctor form and then come back, the combobox is loaded with the proper values.

If that can be made to work, then my only issue is the best way to load the grid with the doctors for the family, hoping that maybe the _user relationsihp will fix that?

I feel like I'm close.

Alan

6

(7 replies, posted in General)

I am not sure how to define this in the Database Tables area.

I have a user table. It's called _user because I'm using the roles feature.

I have a Person table so each user can add a number of persons. I have a relationship of _user in it.

I have a Medication table so each Person can have a list of their medications. I have a relationship with Person in it.

I now want to have a table of Doctor names. It probably would be one set of doctors for the whole family so at the _user level, however each medication will need something that identifies which doctor this is for.

I don't know how to design that. I want a combobox in the Medications form that would show the doctors, then be able to pick one.

Maybe I need to relationships??? One to Medications and one to _user????

7

(9 replies, posted in General)

Derek,
Thanks
Alan

8

(9 replies, posted in General)

If I do this on the OnClick event, I believe I get the right info.

Will test some more

9

(9 replies, posted in General)

I tried this also but that didn't work either..

It seems to update the modified date on adds.

begin
        If frmMedications.dbAction <> 'NewRecord'   then
        Begin
            SQLExecute('Update Medications set ModifiedDate = CurDate() Where ID = ' + frmPerson.tablegrid1.sqlvalue );
        End;
end;

Looks like the value of dbAction is 'SaveRecord'
But it's SaveRecord on the add of new and also the save of the modify.

Obviously I'm confused.

10

(9 replies, posted in General)

Derek,
If I don't want to go to the work of adding extra fields to tell if the actual values have changed, and just want to update modified date if they click save, but only if it's not a new record, how could I do this?

procedure frmMedications_Button5_OnAfterClick (Sender: TObject);
begin
        If Action <> 'NewRecord'  then
        Begin
            SQLExecute('Update Medications set ModifiedDate = CurDate() Where ID = ' + frmPerson.tablegrid1.sqlvalue );
        End;
end;

I tried this but either have a typo or something in it.

11

(9 replies, posted in General)

This is what I have so far.

I was trying to load today's date to test, but trying to get it to be automatic.

   frmmPerson.dtDateAdded.sqlDate := '2020-12-09'; //strftime('%Y-%M-%D',DATE('now'));

12

(9 replies, posted in General)

I have a field called DateAdded in my Person table.

When I'm adding a new record what's the best way to load todays date into the field so it's there when I save the record?

Also if I want to do the same thing with a DataModified field when the user modifies the record.

I've tried searching but just not quite seeing how to do it.

Alan

I did a tablegrid1.dbUpdate on the OnShow event for the form1 and it worked.

I think it's an issue the first time I go into it.
I added a form to add a record and once it's added, and the form is closed the grid shows all the proper records.

So I think I just need to trigger the grid to load.

Alan

How do I enable Auto Execution of the query? I think I have everything setup correctly in the Set up auto query screen but I'm getting no results. I don't have a search button, just want to display the data in the table.

16

(7 replies, posted in General)

Thanks everyone.
Love my MVD.

17

(2 replies, posted in General)

Thanks so much.

I think I understand now.

18

(2 replies, posted in General)

I am getting ready to create my first report.

What I need is a form that the user can enter some criteria. It will probably be a combobox, a date field, and probably a checkbox or two.

I then want to use that criteria for the report.

I don't know the best way to do that. Is there a way for my app to create the query text based on the criteria and pass that to the report?

Don't know best way to accomplish this.

Thanks

19

(7 replies, posted in General)

Brian,
Worked perfectly.

Thanks


and the other suggestions too are now in my toolbox..

Alan

20

(7 replies, posted in General)

Would it be best to use the sqlexecute technique to load the grid with the one row i want?

21

(7 replies, posted in General)

Derek,

Thanks,

How can I add a filter so that when there are many rows in the table like _user to only filter for the current logged in user?

Alan

22

(7 replies, posted in General)

This might be a dumb question, but every sample app I look at uses a Grid to show the records and then you either double click or select Edit to modify the data.

How does one edit a record when there is only one record, or only one record that the user sees, for example, how does the user edit his first name and last name on his _user record when using roles?

I have a form called frmUser that has the fields but I don't understand how to load the data into it??? Is the best way onShow to grab the data for the user and put it in the text boxes, etc??? or is there a better way?

Thanks
Alan

23

(30 replies, posted in General)

Thanks, as always.

Alan

24

(30 replies, posted in General)

Thanks
In this case the Change Password form is hidden so I don't know the names of the edit fields.

But yes, if I had that info, I could use your technique.

Alan

25

(30 replies, posted in General)

CDB wrote:

You might be able to bend the Change Password form to do some of what you want instead of creating a complete form from scratch.


To call the inbuilt change password form  you can choose from:



procedure form1_btnUser_OnClick (Sender: TObject; var Cancel: boolean);
begin

    //frmdbCoreUsers.ShowModal;
    Form1.mniUsers.click;
end;

procedure Form1_btnPassword_OnClick (Sender: TObject; var Cancel: boolean);
begin

   //frmdbCoreUserForm.ShowModal;
   Form1.mniChangePassword.click;
   //frmdbCoreUserChangePwd.show;
end;

The buttons are ones I've placed elsewhere in my program, but you could take Brian's code and place either the mniXXXX or the frmdbCoreUserXX in the code he has for the two buttons he has used.

CDB or anyone, It's a bit unusual to be able to see the old and new password. Is there a way to mask what the user is typing?