Need to: Vba code to get data from table to form automatically by clicking abutton

a7mad1990

New member
Local time
Today, 12:13
Joined
Feb 17, 2023
Messages
26
I have tables named "TblWorksOnly" it has id, worktype and workname fields it has 22 fixed records i need ,"TblCustomers" it has Custfullname and id fields ,"TblLocations" it has idloc and LocName fields

and a form named "FRM_TblWorksOnly"

i need code vba to get data automatically from TblworksOnly based on comboboxs "CmbCustFullName", "LocName" ,"Worktype"


how to do this with button for each customer without repetition for one customer

thanks for all

Ahmed Amer
 
not clear on your description - where are the comboboxes? on your frmtblworksonly or another form? if another form, is the frmtblworksonly a subform on this form?

and what does 'with button for each customer without repetition for one customer' mean? you have 22 buttons scattered around a form? one button?

what are the rowsources to your combos and which is the bound column?

as a guess, perhaps use the where parameter of the openform method?
 
Here Attach I That mean

thanks CJ_London
 

Attachments

  • Vba.png
    Vba.png
    227.5 KB · Views: 131
  • vba 2.png
    vba 2.png
    226.8 KB · Views: 126
  • vba 3.png
    vba 3.png
    233.4 KB · Views: 131
Last edited:
OK

1. your 3 combo's should be unbound (not clear if they are or not)
2. you are using a continuous form, so you need to apply a filter or restate the form recordsource
3. in the button click event to apply a filter use code along the lines
  • me.filter="CustName = '" & cboCustFullName & "' and LocID=" & cboLocName & " and Worktype = " & cboworktype
  • me.filteron=true
you have not explained the rowsources and bound columns of your combos or the field types in your tables so the filter will need adjusting for these.
 
but this code will get filter data i Entry Manual
i need automatic data entry for WorkName "22 Record" from TblWorksOnly by select 3 combobox to this form when i click button

Get Data Automatically by Button to each customer i selescted without repetition
 
Sorry, really not clear what you require - are you saying you want those 3 fields to be autopopulated for new records?
If so in your button click event put something like

CustName.default = cboCustFullName
LocID.default=cboLocName
Worktype.default =cboworktype

as before, no idea of your combo rowsources

or perhaps you don't need the button, use the form current event to set these values if it is a new record.

you could then lock these three controls so users can't change them
 
i need same this method but by getting the data from WorkName "22 Record" from TblWorksOnly sort by id
 

Attachments

  • Animation.gif
    Animation.gif
    153 KB · Views: 118
apply a filter as described in post #4 but just for that field
 

Users who are viewing this thread

Back
Top Bottom